php-nlp-tools
php-nlp-tools copied to clipboard
FeatureBasedNB precomputed trained data
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.
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.
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.