Hi,
Here is my code in order to predict a numeric attribute. I am happy with the output of this code but:
trainData.setClassIndex(trainData.numAttributes()-2);
testData.setClassIndex(testData.numAttributes()-2);
AttributeSelectedClassifier classifier = new AttributeSelectedClassifier();
CfsSubsetEval eval = new CfsSubsetEval();
GreedyStepwise search = new GreedyStepwise();
search.setSearchBackwards(true);
IBk knn2 = new IBk();
String[] options2 = new String[1];
options2[0]= "-I";
knn2.setOptions(options2);
knn2.setKNN(40);
classifier.setClassifier(knn2);
classifier.setEvaluator(eval);
classifier.setSearch(search);
classifier.buildClassifier(trainData);
/* for(int i=0; i<= testData.numInstances()-1; i++)
{
double c = classifier.classifyInstance(testData.instance(i));
}
But when I evaluate the classifier by following three lines
Evaluation ev = new Evaluation(trainData);
ev.evaluateModel(classifier,testData);
System.out.println(ev.toSummaryString());
...just after the line "classifier.buildClassifier(trainData);" , I get this output that shows the results are very bad:
Correlation coefficient 0.315
Mean absolute error 72.3435
Root mean squared error 132.2347
Relative absolute error 89.4112 %
Root relative squared error 96.4757 %
Total Number of Instances 12735
1- Do you think I should change my code because the evaluation shows that the result is not good? Or should I ignore the evaluation information?
2- What is wrong with my code and how can I make it better?
Here is my code in order to predict a numeric attribute. I am happy with the output of this code but:
trainData.setClassIndex(trainData.numAttributes()-2);
testData.setClassIndex(testData.numAttributes()-2);
AttributeSelectedClassifier classifier = new AttributeSelectedClassifier();
CfsSubsetEval eval = new CfsSubsetEval();
GreedyStepwise search = new GreedyStepwise();
search.setSearchBackwards(true);
IBk knn2 = new IBk();
String[] options2 = new String[1];
options2[0]= "-I";
knn2.setOptions(options2);
knn2.setKNN(40);
classifier.setClassifier(knn2);
classifier.setEvaluator(eval);
classifier.setSearch(search);
classifier.buildClassifier(trainData);
/* for(int i=0; i<= testData.numInstances()-1; i++)
{
double c = classifier.classifyInstance(testData.instance(i));
}
But when I evaluate the classifier by following three lines
Evaluation ev = new Evaluation(trainData);
ev.evaluateModel(classifier,testData);
System.out.println(ev.toSummaryString());
...just after the line "classifier.buildClassifier(trainData);" , I get this output that shows the results are very bad:
Correlation coefficient 0.315
Mean absolute error 72.3435
Root mean squared error 132.2347
Relative absolute error 89.4112 %
Root relative squared error 96.4757 %
Total Number of Instances 12735
1- Do you think I should change my code because the evaluation shows that the result is not good? Or should I ignore the evaluation information?
2- What is wrong with my code and how can I make it better?