Java examples for Machine Learning AI:weka
Create weka classifiers trees J48
import weka.classifiers.Classifier; import weka.classifiers.Evaluation; import weka.classifiers.bayes.NaiveBayes; import weka.classifiers.meta.Dagging; import weka.classifiers.misc.SerializedClassifier; import weka.classifiers.rules.JRip; import weka.classifiers.trees.J48; import weka.core.Instances; import java.io.BufferedReader; import java.io.FileReader; public class Weka { public static void main(String[] args) throws Exception { Classifier cls_1 = new J48(); // load data sets Instances train = new Instances(new BufferedReader(new FileReader("anneal_train.arff"))); train.setClassIndex(train.numAttributes() - 1); cls_1.buildClassifier(train);/*from w w w .j ava 2 s .c o m*/ // serialization weka.core.SerializationHelper.write("anneal.model", cls_1); } }