Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Export Weka Models for Use in C or C++

I have had a great deal of success using Weka for data exploration and deciding what classification algorithm is best for my problem. Now that I have a trained model that works, I would like to integrate it into the rest of my C++ program. Unfortunately, this seems like a difficult task: only Weka has native support for exporting classifiers as Java object files. Has anyone found a way to export Weka-trained model parameters in a useful format?

I would be particularly interested if there is a utility that generates C/C++ code from a J48 decision tree.

like image 846
Michael Koval Avatar asked May 14 '11 22:05

Michael Koval


People also ask

How to Load a model in Weka?

right-click in the Results list, select Load model and choose /other/place/j48. model. in the More options dialog, change the Output predictions to CSV or another format (and specify a file in the options of the output format), if you want to store the predictions in a file rather than having to copy/paste them.


2 Answers

My understanding is that J48 is Java implementation of Quinlan C4.5 algorithm with C code freely available at http://www.rulequest.com/Personal/ Is this what you are looking for?

like image 64
Nikiton Avatar answered Sep 21 '22 14:09

Nikiton


J48 implements the Sourcable interface, meaning it can output a built model as Java source code (you can probably achieve this from the classifier panel of the explorer gui). It might then be possible to automatically translate this into C/C++.

like image 24
Len Trigg Avatar answered Sep 20 '22 14:09

Len Trigg