Skip to content

Commit

Permalink
Fix serialization of GaussianNaiveBayes
Browse files Browse the repository at this point in the history
  • Loading branch information
vigsterkr committed Jun 14, 2017
1 parent 9efa3b7 commit 25c71a5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/shogun/multiclass/GaussianNaiveBayes.cpp
Expand Up @@ -23,14 +23,15 @@ CGaussianNaiveBayes::CGaussianNaiveBayes() : CNativeMulticlassMachine(), m_featu
m_min_label(0), m_num_classes(0), m_dim(0), m_means(), m_variances(),
m_label_prob(), m_rates()
{

init();
};

CGaussianNaiveBayes::CGaussianNaiveBayes(CFeatures* train_examples,
CLabels* train_labels) : CNativeMulticlassMachine(), m_features(NULL),
m_min_label(0), m_num_classes(0), m_dim(0), m_means(),
m_variances(), m_label_prob(), m_rates()
{
init();
ASSERT(train_examples->get_num_vectors() == train_labels->get_num_labels())
set_labels(train_labels);

Expand Down Expand Up @@ -226,3 +227,19 @@ float64_t CGaussianNaiveBayes::apply_one(int32_t idx)

return max_label_idx+m_min_label;
};

void CGaussianNaiveBayes::init()
{
SG_ADD(&m_min_label, "m_min_label", "minimal label", MS_NOT_AVAILABLE);
SG_ADD(&m_num_classes, "m_num_classes",
"number of different classes (labels)", MS_NOT_AVAILABLE);
SG_ADD(&m_dim, "m_dim",
"dimensionality of feature space", MS_NOT_AVAILABLE);
SG_ADD(&m_means, "m_means",
"means for normal distributions of features", MS_NOT_AVAILABLE);
SG_ADD(&m_variances, "m_variances",
"variances for normal distributions of features", MS_NOT_AVAILABLE);
SG_ADD(&m_label_prob, "m_label_prob",
"a priori probabilities of labels", MS_NOT_AVAILABLE);
SG_ADD(&m_rates, "m_rates", "label rates", MS_NOT_AVAILABLE);
}
3 changes: 3 additions & 0 deletions src/shogun/multiclass/GaussianNaiveBayes.h
Expand Up @@ -96,6 +96,9 @@ class CGaussianNaiveBayes : public CNativeMulticlassMachine
*/
virtual bool train_machine(CFeatures* data=NULL);

private:
void init();

protected:

/// features for training or classifying
Expand Down

0 comments on commit 25c71a5

Please sign in to comment.