Java tutorial
/* * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ /** * WekaEvaluationToMarginCurve.java * Copyright (C) 2014 University of Waikato, Hamilton, New Zealand */ package adams.data.conversion; import weka.classifiers.Evaluation; import weka.classifiers.evaluation.MarginCurve; import weka.core.Instances; /** <!-- globalinfo-start --> * Generates margin-curve data from a WEKA Evaluation object. * <br><br> <!-- globalinfo-end --> * <!-- options-start --> * <pre>-logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel) * The logging level for outputting errors and debugging output. * default: WARNING * </pre> * <!-- options-end --> * * @author fracpete (fracpete at waikato dot ac dot nz) * @version $Revision$ */ public class WekaEvaluationToMarginCurve extends AbstractConversion { /** for serialization. */ private static final long serialVersionUID = -3340269698168769770L; /** * Returns a string describing the object. * * @return a description suitable for displaying in the gui */ @Override public String globalInfo() { return "Generates margin-curve data from a WEKA Evaluation object."; } /** * Returns the class that is accepted as input. * * @return the class */ @Override public Class accepts() { return Evaluation.class; } /** * Returns the class that is generated as output. * * @return the class */ @Override public Class generates() { return Instances.class; } /** * Performs the actual conversion. * * @return the converted data * @throws Exception if something goes wrong with the conversion */ @Override protected Object doConvert() throws Exception { Evaluation eval; MarginCurve curve; Instances cost; eval = (Evaluation) m_Input; curve = new MarginCurve(); cost = curve.getCurve(eval.predictions()); return cost; } }