Bundle Machine learning library with linear regression, logistic regression, k-means clustering, and matrix operations. Designed for tabular data; supports training, prediction, and model evaluation. Compile with -lib ml.
NaiveBayes
Naive Bayes ML algorithm
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();
}Operations
New # constructor
Constructor
New(left:BayesGroup, right:BayesGroup)Parameters
| Name | Type | Description |
|---|---|---|
| left | BayesGroup | left group |
| right | BayesGroup | right group |