Naive Bayes ML algorithm
OperationsCode example:
normal := BayesGroup->New(8.0 / 12.0);
normal->AddEntry(BayesEntry->New("dear", 8));
normal->AddEntry(BayesEntry->New("friend", 5));
normal->AddEntry(BayesEntry->New("lunch", 3));
normal->AddEntry(BayesEntry->New("money", 1));
spam := BayesGroup->New(4.0 / 12.0);
spam->AddEntry(BayesEntry->New("dear", 2));
spam->AddEntry(BayesEntry->New("friend", 1));
spam->AddEntry(BayesEntry->New("lunch", 0));
spam->AddEntry(BayesEntry->New("money", 4));
bayes := NaiveBayes->New(normal, spam);
finding := bayes->Query(["lunch", "money", "money", "money", "money"]);
if(finding = 0) {
"normal"->PrintLine();
}
else if(finding = 1) {
"spam"->PrintLine();
}
else {
"invalid"->PrintLine();
}
Constructor
New(left:BayesGroup, right:BayesGroup)
Name | Type | Description |
---|---|---|
left | BayesGroup | left group |
right | BayesGroup | right group |
Query to Naive Bayes
method : public : Query(terms:String[]) ~ Int
Name | Type | Description |
---|---|---|
terms | String[] | list of term to calculate |
Type | Description |
---|---|
Int | 0 if left, 1 if right, -1 otherwise |