statistical-classifier icon indicating copy to clipboard operation
statistical-classifier copied to clipboard

Unrecognized options "0, 1, 2" under "datasource.ok"

Open carbontwelve opened this issue 8 years ago • 1 comments

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.

carbontwelve avatar Aug 15 '16 13:08 carbontwelve

Shouldn't

$classifier = new ComplementNaiveBayes($dataArr);

be after foreach?

nimasdj avatar Aug 29 '16 10:08 nimasdj