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

Append an existing model

Open sonalmahajan01 opened this issue 8 years ago • 4 comments

Hi,

Can we somehow read an existing model and append to it?

Thanks and Regards, Sonal

sonalmahajan01 avatar Jul 26 '16 06:07 sonalmahajan01

If you add a new document to a existing data source, and then set the model to unprepared $model->setPrepared(false); then when you try to classify something it will regenerate the model. But no there isn't a way to append to an existing model without recomputing.

camspiers avatar Jul 26 '16 22:07 camspiers

Hi,

Thanks for the prompt reply. Actually my requirement was to generate model using a document records. and then based on scenario change, append another document records to the same model so i don't have to store all the files used for creating the model.

Any way this can be done with the current version?

Thanks and Regards, Sonal

sonalmahajan01 avatar Jul 27 '16 02:07 sonalmahajan01

I don't think that option is available at the moment sorry :(

camspiers avatar Jul 27 '16 19:07 camspiers

Hi, One more question related to the above question. Can we use multiple models for classification of a document? Like for loading classifiers: public static function Factory($files){ if(empty($files) || count($files) != 1){ throw new \Exception("No file to load"); } $classifierfile = $files[0]; if(!is_file($classifierfile)){ throw new \Exception("unable to find .model file!"); } $fp = fopen($classifierfile, "r"); $content = fread($fp, filesize($classifierfile)); fclose($fp);

$classifier = unserialize($content);
unlink($classifierfile);
return $classifier;

} Cause the parameter is $files, can i send an array of files and loop through them and read them. In that case ho do i deal with $classifier = unserialize($content);

If this can somehow work, then we dont need to append a model but use multiple models to classify a document.

Many thanks, Sonal

sonalmahajan01 avatar Aug 15 '16 06:08 sonalmahajan01