Vorhersage mit WEKA in Java ausdrucken
Ich versuche, mit Weka in Java mithilfe des Naive Bayes-Klassifikators eine Vorhersage mit folgendem Code zu treffen:
JAVpublic class Run {
public static void main(String[] args) throws Exception {
ConverterUtils.DataSource source1 = new ConverterUtils.DataSource("./data/train.arff");
Instances train = source1.getDataSet();
// setting class attribute if the data format does not provide this information
// For example, the XRFF format saves the class attribute information as well
if (train.classIndex() == -1)
train.setClassIndex(train.numAttributes() - 1);
ConverterUtils.DataSource source2 = new ConverterUtils.DataSource("./data/test.arff");
Instances test = source2.getDataSet();
// setting class attribute if the data format does not provide this information
// For example, the XRFF format saves the class attribute information as well
if (test.classIndex() == -1)
test.setClassIndex(train.numAttributes() - 1);
// model
NaiveBayes naiveBayes = new NaiveBayes();
naiveBayes.buildClassifier(train);
Evaluation evaluation = new Evaluation(train);
evaluation.evaluateModel(naiveBayes, test);
}
}
ZU@relation weather
@attribute outlook {sunny, overcast, rainy}
@attribute temperature real
@attribute humidity real
@attribute windy {TRUE, FALSE}
@attribute play {yes, no}
@data
sunny,85,85,FALSE,no
sunny,80,90,TRUE,no
...
VORHERSAGE@relation weather
@attribute outlook {sunny, overcast, rainy}
@attribute temperature real
@attribute humidity real
@attribute windy {TRUE, FALSE}
@attribute play {yes, no}
@data
sunny,85,85,FALSE,?
In demGUI
die vorhergesagte Ausgabe ist
=== Predictions on test split ===
inst#, actual, predicted, error, probability distribution
1 ? 2:no + 0.145 *0.855
Wie kann ich diese Ausgabe mit Java erhalten? Welche Methode muss ich verwenden, um das zu bekommen?