Fixed crashes and errors.

This commit is contained in:
Relintai 2023-12-28 12:03:17 +01:00
parent fe4ac8625c
commit 7b0d147aa3
2 changed files with 6 additions and 1 deletions

View File

@ -85,7 +85,9 @@ MLPPBernoulliNB::MLPPBernoulliNB(const Ref<MLPPMatrix> &p_input_set, const Ref<M
_prior_1 = 0;
_prior_0 = 0;
_vocab.instance();
_y_hat.instance();
_y_hat->resize(_output_set->size());
evaluate();
@ -157,7 +159,7 @@ void MLPPBernoulliNB::evaluate() {
Vector<int> found_indices;
for (int j = 0; j < _input_set->size().y; j++) {
for (int j = 0; j < _input_set->size().x; j++) {
for (int k = 0; k < _vocab->size(); k++) {
if (_input_set->element_get(i, j) == _vocab->element_get(k)) {
score_0 += Math::log(static_cast<real_t>(_theta[0][_vocab->element_get(k)]));

View File

@ -135,7 +135,10 @@ MLPPMultinomialNB::MLPPMultinomialNB(const Ref<MLPPMatrix> &p_input_set, const R
_output_set = p_output_set;
_class_num = pclass_num;
_priors.instance();
_vocab.instance();
_y_hat.instance();
_y_hat->resize(_output_set->size());
_initialized = true;