Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I load a Weka model in Java?

I have saved the result of a Weka classification by right-clicking on the model and selecting "save model". Now, I want to load it and work with it in my Java application. How can I do that? Models could be naive Bayes, decision trees, or regression. I need to use these three models.

Any suggestion or solution would be appreciated.

like image 343
Prabodha Dissanayake Avatar asked Jan 08 '13 06:01

Prabodha Dissanayake


1 Answers

Here is an example assuming you have a RandomTree model saved to a model.weka file (change to whatever classifier and file you have)

RandomTree treeClassifier = (RandomTree) SerializationHelper.read(new FileInputStream("model.weka")));
like image 62
iTech Avatar answered Sep 20 '22 11:09

iTech