use of weka.classifiers.Evaluation in project dkpro-tc by dkpro.
the class WekaResultsTest method testWekaResultsSingleLabel.
@Test
public void testWekaResultsSingleLabel() throws Exception {
SMO cl = new SMO();
Instances testData = WekaUtils.makeOutcomeClassesCompatible(singleLabelTrainData, singleLabelTestData, false);
Instances trainData = WekaUtils.removeInstanceId(singleLabelTrainData, false);
testData = WekaUtils.removeInstanceId(testData, false);
cl.buildClassifier(trainData);
Evaluation eval = WekaUtils.getEvaluationSinglelabel(cl, trainData, testData);
assertEquals(7.0, eval.correct(), 0.01);
}
use of weka.classifiers.Evaluation in project dkpro-tc by dkpro.
the class WekaUtils method getEvaluationSinglelabel.
/**
* Evaluates a given single-label classifier on given train and test sets.
*
* @param cl
* classifier
* @param trainData
* weka training instances
* @param testData
* weka test instances
* @return Evaluation object
* @throws Exception
* in case of errors
*/
public static Evaluation getEvaluationSinglelabel(Classifier cl, Instances trainData, Instances testData) throws Exception {
Evaluation eval = new Evaluation(trainData);
eval.evaluateModel(cl, testData);
return eval;
}
use of weka.classifiers.Evaluation in project dkpro-tc by dkpro.
the class WekaArffTest method main.
/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
File train = new File("src/main/resources/arff/manyInstances/train.arff.gz");
File test = new File("src/main/resources/arff/manyInstances/test.arff.gz");
Instances trainData = WekaUtils.getInstances(train, false);
Instances testData = WekaUtils.getInstances(test, false);
Classifier cl = new NaiveBayes();
// no problems until here
Evaluation eval = new Evaluation(trainData);
eval.evaluateModel(cl, testData);
}
use of weka.classifiers.Evaluation in project dkpro-tc by dkpro.
the class WekaResultsTest method testWekaResultsRegression.
@Test
public void testWekaResultsRegression() throws Exception {
SMOreg cl = new SMOreg();
Instances trainData = WekaUtils.removeInstanceId(regressionTrainData, false);
Instances testData = WekaUtils.removeInstanceId(regressionTestData, false);
cl.buildClassifier(trainData);
Evaluation eval = WekaUtils.getEvaluationSinglelabel(cl, trainData, testData);
assertEquals(0.45, eval.correlationCoefficient(), 0.01);
}
Aggregations