Reputation: 1421
I need to get the threshold curve from my trained classifiers automatically, so I'm figuring out how to do this with the command line (currently using Weka's SimpleCLI). Following the output from java weka.classifiers.functions.Logistic -h
I'm trying to use the -threshold-file
argument, described as:
-threshold-file <file>
The file to save the threshold data to.
The format is determined by the extensions, e.g., '.arff' for ARFF
format or '.csv' for CSV.
This is the line I'm trying to execute from the SimpleCLI (broken in 2 parts for ease of read):
java weka.classifiers.functions.Logistic -t ".\data\iris.arff" -no-cv -R 1.0E-8 -M -1 \
-threshold-file "C:\Temp\somefile.csv"
Which gives me either this:
java.lang.NullPointerException
or this (or both):
weka.classifiers.evaluation.ThresholdCurve.getCurve(ThresholdCurve.java:125)
weka.classifiers.evaluation.Evaluation.evaluateModel(Evaluation.java:1739)
weka.classifiers.Evaluation.evaluateModel(Evaluation.java:650)
weka.classifiers.AbstractClassifier.runClassifier(AbstractClassifier.java:359)
weka.classifiers.functions.Logistic.main(Logistic.java:1134)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
weka.gui.SimpleCLIPanel$ClassRunner.run(SimpleCLIPanel.java:199)
at weka.classifiers.evaluation.ThresholdCurve.getCurve(ThresholdCurve.java:125)
at weka.classifiers.evaluation.Evaluation.evaluateModel(Evaluation.java:1739)
at weka.classifiers.Evaluation.evaluateModel(Evaluation.java:650)
at weka.classifiers.AbstractClassifier.runClassifier(AbstractClassifier.java:359)
at weka.classifiers.functions.Logistic.main(Logistic.java:1134)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at weka.gui.SimpleCLIPanel$ClassRunner.run(SimpleCLIPanel.java:199)
(Executing this from Windows cmd.exe gives me roughly the same messages. Note that I'm using Weka 3.7.11 in a Windows 7 machine (64 bits) and Java 7 (Update 55).)
Note that deleting the last part will make the command work ok, although not creating the desired threshold file.
I've tried many variants of this line, with the same result. I'm not familiar with java. What I need is to know how I'm doing this wrong.
Thanks in advance.
Update: it was pointed out to me that the line weka.classifiers.evaluation.ThresholdCurve.getCurve(ThresholdCurve.java:125)
is:
if ((predictions.size() == 0)
|| (((NominalPrediction) predictions.get(0)).distribution().length <= classIndex)) {
return null;
}
(source)
So it seems that the problem arises because there are no predictions made at all. I don't know why would this happen and how I can reverse it.
Upvotes: 0
Views: 487
Reputation: 176
The code you are using to invoke the simple cli classifier does not generate any evaluation result, based upon which you can get the threshold curve.
You can do the following.
Upvotes: 1