mirror of
https://github.com/Relintai/pmlpp.git
synced 2024-12-22 15:06:47 +01:00
Fixed crashes and errors.
This commit is contained in:
parent
fe4ac8625c
commit
7b0d147aa3
@ -85,7 +85,9 @@ MLPPBernoulliNB::MLPPBernoulliNB(const Ref<MLPPMatrix> &p_input_set, const Ref<M
|
|||||||
_prior_1 = 0;
|
_prior_1 = 0;
|
||||||
_prior_0 = 0;
|
_prior_0 = 0;
|
||||||
|
|
||||||
|
_vocab.instance();
|
||||||
_y_hat.instance();
|
_y_hat.instance();
|
||||||
|
|
||||||
_y_hat->resize(_output_set->size());
|
_y_hat->resize(_output_set->size());
|
||||||
|
|
||||||
evaluate();
|
evaluate();
|
||||||
@ -157,7 +159,7 @@ void MLPPBernoulliNB::evaluate() {
|
|||||||
|
|
||||||
Vector<int> found_indices;
|
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++) {
|
for (int k = 0; k < _vocab->size(); k++) {
|
||||||
if (_input_set->element_get(i, j) == _vocab->element_get(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)]));
|
score_0 += Math::log(static_cast<real_t>(_theta[0][_vocab->element_get(k)]));
|
||||||
|
@ -135,7 +135,10 @@ MLPPMultinomialNB::MLPPMultinomialNB(const Ref<MLPPMatrix> &p_input_set, const R
|
|||||||
_output_set = p_output_set;
|
_output_set = p_output_set;
|
||||||
_class_num = pclass_num;
|
_class_num = pclass_num;
|
||||||
|
|
||||||
|
_priors.instance();
|
||||||
|
_vocab.instance();
|
||||||
_y_hat.instance();
|
_y_hat.instance();
|
||||||
|
|
||||||
_y_hat->resize(_output_set->size());
|
_y_hat->resize(_output_set->size());
|
||||||
|
|
||||||
_initialized = true;
|
_initialized = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user