php-nlp-tools icon indicating copy to clipboard operation
php-nlp-tools copied to clipboard

FeatureBasedNB precomputed trained data

Open gradzio opened this issue 7 years ago • 2 comments

Hey, the constructor in FeatureBasedNB should allow this:

public function __construct($priors = [], $condprob = []) { $this->priors = $priors; $this->condprob = $condprob; $this->unknown = []; }

this way we would be able to cache / store trained properties and then inject them before classifying. Now one has to train the model each time calling the classify or getScore on classifier.

gradzio avatar Jan 31 '18 13:01 gradzio

The concept was to simply serialize and unserialize the model, but you may be right and perhaps it should be added. I 'll look into that when I have some time. For now you can just serialize and unserialize the model so that you don't have to train again.

angeloskath avatar Feb 01 '18 10:02 angeloskath

Hey no problem, i am using it right now in my own project. I will make pull request later today :), serialization does not always work, depending on the caching system used.

gradzio avatar Feb 01 '18 10:02 gradzio