angeloskath / php-nlp-tools

Natural Language Processing Tools in PHP
Do What The F*ck You Want To Public License
743 stars 152 forks source link

FeatureBasedNB precomputed trained data #60

Open gradzio opened 6 years ago

gradzio commented 6 years ago

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.

angeloskath commented 6 years ago

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.

gradzio commented 6 years ago

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.