int folds;
String tmpStr;
boolean compute;
Instances result;
String[] options;
SingleIndex classIndex;
SingleIndex valueIndex;
int seed;
inst = null;
classifier = null;
runs = 2;
folds = 10;
compute = true;
result = null;
classIndex = null;
valueIndex = null;
seed = 1;
try {
// help?
if (Utils.getFlag('h', args)) {
System.out.println(Messages.getInstance().getString("ThresholdVisualizePanel_Main_Text_First") + ThresholdVisualizePanel.class.getName() + Messages.getInstance().getString("ThresholdVisualizePanel_Main_Text_Second"));
System.out.println(Messages.getInstance().getString("ThresholdVisualizePanel_Main_Text_Third"));
System.out.println(Messages.getInstance().getString("ThresholdVisualizePanel_Main_Text_Fourth"));
System.out.println(Messages.getInstance().getString("ThresholdVisualizePanel_Main_Text_Fifth"));
System.out.println(Messages.getInstance().getString("ThresholdVisualizePanel_Main_Text_Sixth"));
System.out.println(Messages.getInstance().getString("ThresholdVisualizePanel_Main_Text_Seventh"));
System.out.println(Messages.getInstance().getString("ThresholdVisualizePanel_Main_Text_Eighth"));
System.out.println(Messages.getInstance().getString("ThresholdVisualizePanel_Main_Text_Nineth"));
System.out.println(Messages.getInstance().getString("ThresholdVisualizePanel_Main_Text_Tenth"));
System.out.println(Messages.getInstance().getString("ThresholdVisualizePanel_Main_Text_Eleventh"));
return;
}
// regular options
tmpStr = Utils.getOption('l', args);
if (tmpStr.length() != 0) {
result = new Instances(new BufferedReader(new FileReader(tmpStr)));
compute = false;
}
if (compute) {
tmpStr = Utils.getOption('r', args);
if (tmpStr.length() != 0)
runs = Integer.parseInt(tmpStr);
else
runs = 1;
tmpStr = Utils.getOption('x', args);
if (tmpStr.length() != 0)
folds = Integer.parseInt(tmpStr);
else
folds = 10;
tmpStr = Utils.getOption('S', args);
if (tmpStr.length() != 0)
seed = Integer.parseInt(tmpStr);
else
seed = 1;
tmpStr = Utils.getOption('t', args);
if (tmpStr.length() != 0) {
inst = new Instances(new BufferedReader(new FileReader(tmpStr)));
inst.setClassIndex(inst.numAttributes() - 1);
}
tmpStr = Utils.getOption('W', args);
if (tmpStr.length() != 0) {
options = Utils.partitionOptions(args);
}
else {
tmpStr = weka.classifiers.functions.Logistic.class.getName();
options = new String[0];
}
classifier = Classifier.forName(tmpStr, options);
tmpStr = Utils.getOption('c', args);
if (tmpStr.length() != 0)
classIndex = new SingleIndex(tmpStr);
else
classIndex = new SingleIndex("last");
tmpStr = Utils.getOption('C', args);
if (tmpStr.length() != 0)
valueIndex = new SingleIndex(tmpStr);
else
valueIndex = new SingleIndex("first");
}
// compute if necessary
if (compute) {
if (classIndex != null) {
classIndex.setUpper(inst.numAttributes() - 1);
inst.setClassIndex(classIndex.getIndex());
}
else {
inst.setClassIndex(inst.numAttributes() - 1);
}
if (valueIndex != null) {
valueIndex.setUpper(inst.classAttribute().numValues() - 1);
}
ThresholdCurve tc = new ThresholdCurve();
EvaluationUtils eu = new EvaluationUtils();
FastVector predictions = new FastVector();
for (int i = 0; i < runs; i++) {
eu.setSeed(seed + i);
predictions.appendElements(eu.getCVPredictions(classifier, inst, folds));
}
if (valueIndex != null)
result = tc.getCurve(predictions, valueIndex.getIndex());
else
result = tc.getCurve(predictions);
}
// setup GUI
ThresholdVisualizePanel vmc = new ThresholdVisualizePanel();
vmc.setROCString(Messages.getInstance().getString("ThresholdVisualizePanel_OpenVisibleInstances_Text_Third") +
Utils.doubleToString(ThresholdCurve.getROCArea(result), 4) + Messages.getInstance().getString("ThresholdVisualizePanel_OpenVisibleInstances_Text_Fourth"));
if (compute)
vmc.setName(
result.relationName()
+ Messages.getInstance().getString("ThresholdVisualizePanel_Main_Text_Twelveth") + inst.classAttribute().value(valueIndex.getIndex()) + Messages.getInstance().getString("ThresholdVisualizePanel_Main_Text_Thirteenth"));
else
vmc.setName(
result.relationName()
+ Messages.getInstance().getString("ThresholdVisualizePanel_Main_Text_Fourteenth"));
PlotData2D tempd = new PlotData2D(result);