statistical-classifier
statistical-classifier copied to clipboard
Unrecognized options "0, 1, 2" under "datasource.ok"
I get the error Unrecognized options "0, 1, 2" under "datasource.ok"
when trying to initiate a new DataArray
with the result of getData()
being passed to its constructor.
$dataArr = new DataArray();
$classifier = new ComplementNaiveBayes($dataArr);
$items = [
"hi my name is alex, what about you?" => 'ok',
"are you hungy? what about some fries?" => 'ok',
"how are you?" => 'ok',
"buy viagra or dope" => 'spam',
"viagra spam drugs sex" => 'spam',
"buy drugs and have fun" => 'spam'
];
foreach ($items as $text => $classification) {
$dataArr->addDocument($classification, $text);
}
$classifier->setDataSource($dataArr);
var_dump($classifier->classify('hi guy, how are you?')); //ok
var_dump($classifier->classify('buy viagra?')); //spam
var_dump($classifier->classify('bannana for scale')); //false
$export = $dataArr->getData();
var_dump($export); // error will happen here
I believe I am using this in the way it is intended, so I think this behavior is a bug.
Shouldn't
$classifier = new ComplementNaiveBayes($dataArr);
be after foreach?