Loding a weka model to a java code

Prabodha Dissanayake picture Prabodha Dissanayake · Jan 8, 2013 · Viewed 12.5k times · Source

I have saved the result of weka classification by right clicking on the model and selecting "save model". Now, I want to load it and work with in my "JAVA" application. How can I do that? Models could be Naive bias, Decision tree and regression. I need to use these three models.

Any suggestion or solution would be appreciated.

Thanks.

Answer

iTech picture iTech · Jan 8, 2013

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")));