/** * @param correctLabel The correct label * @param classifiedResult The classified result * @return whether the instance was correct or not */ public boolean addInstance(String correctLabel, ClassifierResult classifiedResult) { boolean result = correctLabel.equals(classifiedResult.getLabel()); if (result) { correctlyClassified++; } else { incorrectlyClassified++; } confusionMatrix.addInstance(correctLabel, classifiedResult); if (classifiedResult.getLogLikelihood() != Double.MAX_VALUE) { summarizer.add(classifiedResult.getLogLikelihood()); hasLL = true; } return result; }
/** * Emit the result from a sub process wrapper back up to whoever called us * * @param res The classifier result. */ @Override protected void _processResults(ClassifierResult res) { System.out.print( "SubProcessWrapper: Time(" + res.getTime() + ") Score(" + res.getScore() + ")"); String outputFilePrefix = mProperties.getProperty("modelOutputFilePrefix", null); if (outputFilePrefix != null) { try { if (res.getAttributeSelection() != null) { weka.core.SerializationHelper.write( outputFilePrefix + ".attributeselection", res.getAttributeSelection()); } else { File oldFile = new File(outputFilePrefix + ".attributeselection"); if (oldFile.exists()) oldFile.delete(); } weka.core.SerializationHelper.write(outputFilePrefix + ".model", res.getClassifier()); } catch (Exception e) { throw new RuntimeException(e); } } }