PDA

View Full Version : Error modifying Weka



pensadoro
10-26-2008, 01:36 PM
Hello, I'm programming a new meta algorithm and integrating it in Weka. This algorithm, now, allows the user to select another algorithm (for example, J48) and evaluates the data with it. That's how I do it:

public void buildClassifier(Instances data) throws Exception {
getCapabilities().testWithFail(data);
data = new Instances(data);
data.deleteWithMissingClass();
m_Classifier.buildClassifier(data);
evaluation = new Evaluation(data);
System.out.println(evaluation.evaluateModel(m_Classifier, data));
}

but when I compile it, in Weka, appears an error after executing it, appears an error:

"Problems evaluating classifier: weka.classifiers.Evaluation"

Can anybody explain me why that happen?

Thank you very much

Mark
10-26-2008, 08:32 PM
Hi,

What sort of data did you test your classifier on? The buildClassifier method completed successfully for me when I tried it on iris.arff (discrete class data). Of course, there was a problem evaluating your classifier because it doesn't override either classifyInstance or distributionForInstance in the Classifier superclass (one or the other of these methods needs to be overriden by subclasses).

Cheers,
Mark.

pensadoro
10-28-2008, 06:32 PM
Hello again, thank you for your answer.

I've implemented those compulsory functions, I've tested with both, only with one of them and then with the other one, but the error remains.

I can see the evaluation, because I print on the screen the corrected classified instances and I can see the number, but at the end: The error appears
"Problems evaluating classifier: weka.classifiers.Evaluation"

I've tested all of my proofs with iris.arff, titanic.arff and diabetes.arff.

I attach you my algorithm.

Thanks a lot for your help ¡¡

pensadoro
10-29-2008, 05:31 PM
Hello again, thank you for your answer.

I've implemented those compulsory functions, I've tested with both, only with one of them and then with the other one, but the error remains.

I can see the evaluation, because I print on the screen the corrected classified instances and I can see the number, but at the end: The error appears
"Problems evaluating classifier: weka.classifiers.Evaluation"

I've tested all of my proofs with iris.arff, titanic.arff and diabetes.arff.

I attach you my algorithm.

Mark
10-29-2008, 08:30 PM
Hi,

I've just tried your latest attachment and I don't see the error (output attached for iris). It also works fine for a cross-validation as well. What version of Weka are you using, which OS, version of Java etc?

Cheers,
Mark.

pensadoro
10-30-2008, 06:19 AM
Hi, it's strange but when I execute my algorithm in Weka I can only see:

------------------------------------------------------------------
In toString: proy2 information.
Selected classifier: weka.classifiers.rules.ZeroR
Selected classifier (another way): weka.classifiers.rules.ZeroR

Percentage correctly classified: 33.333333333333336

Time taken to build model: 0.02 seconds

(here, appears the error in a JOptionPane)
------------------------------------------------------------------

but your output has more information
I use eclipse 3.3.0, jdk 1.60._07 (compiler 1.6), weka 3.4.13 (I'm not sure, but I download it a month ago using CVS) and windows xp

cheers,
Miguel

Mark
10-30-2008, 08:58 PM
OK, I see the problem. I was running from the command line rather than the Explorer. The Explorer makes a copy of the trained classifier to store in the History list (so that you can review it or make further predictions with it later). To do this it uses in memory serialization. Your class is failing to serialize because it has a member variable that holds an Evaluation object. Evaluation is not serializable. Make this variable transient or turn it into a local variable in the buildClassifier method.

Cheers,
Mark.

pensadoro
11-02-2008, 07:13 AM
Thanks a lot, the problem is now fixed. I could have spent days to discover that problem ¡¡

But now I've another problem, I promise you is the last, because from now on I start programming "without Weka".

I try to print the correctly classified instances, error rates... but what I print is different from the summary Weka prints at the end.
I've proved thousand of things, but it's always different. It doesn't matter if evaluation is transient or local, if i imlpement classifyInstance or distributionForInstance or both, if I use a copy or the original dataset...

It must be a problem of evaluation, perhaps I've to use a special trainning set or... I don't know.

I attach you my algorithm.

Cheers,
Miguel

pensadoro
11-03-2008, 05:30 PM
I've just discovered the problem, I was evaluating with cross-validation, and Weka with the trainning set.

Thanks for all your help

Miguel