List of usage examples for weka.classifiers.evaluation MarginCurve getCurve
public Instances getCurve(ArrayList<Prediction> predictions)
From source file:adams.data.conversion.WekaEvaluationToMarginCurve.java
License:Open Source License
/** * Performs the actual conversion.// ww w . ja v a 2 s . c o m * * @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; }
From source file:adams.flow.sink.WekaMarginCurve.java
License:Open Source License
/** * Plots the token (the panel and dialog have already been created at * this stage)./*from w w w . j a va2s . c om*/ * * @param token the token to display */ @Override protected void display(Token token) { weka.classifiers.evaluation.MarginCurve curve; Evaluation eval; PlotData2D plot; boolean[] connectPoints; int cp; Instances data; try { if (token.getPayload() instanceof WekaEvaluationContainer) eval = (Evaluation) ((WekaEvaluationContainer) token.getPayload()) .getValue(WekaEvaluationContainer.VALUE_EVALUATION); else eval = (Evaluation) token.getPayload(); if (eval.predictions() == null) { getLogger().severe("No predictions available from Evaluation object!"); return; } curve = new weka.classifiers.evaluation.MarginCurve(); data = curve.getCurve(eval.predictions()); plot = new PlotData2D(data); plot.m_displayAllPoints = true; connectPoints = new boolean[data.numInstances()]; for (cp = 1; cp < connectPoints.length; cp++) connectPoints[cp] = true; plot.setConnectPoints(connectPoints); m_VisualizePanel.addPlot(plot); } catch (Exception e) { handleException("Failed to display token: " + token, e); } }
From source file:adams.flow.sink.WekaMarginCurve.java
License:Open Source License
/** * Creates a new panel for the token./*from w w w. j a v a 2s.c om*/ * * @param token the token to display in a new panel, can be null * @return the generated panel */ public AbstractDisplayPanel createDisplayPanel(Token token) { AbstractDisplayPanel result; String name; if (token != null) name = "Margin curve (" + getEvaluation(token).getHeader().relationName() + ")"; else name = "Margin curve"; result = new AbstractComponentDisplayPanel(name) { private static final long serialVersionUID = -3513994354297811163L; protected VisualizePanel m_VisualizePanel; @Override protected void initGUI() { super.initGUI(); setLayout(new BorderLayout()); m_VisualizePanel = new VisualizePanel(); add(m_VisualizePanel, BorderLayout.CENTER); } @Override public void display(Token token) { try { Evaluation eval = getEvaluation(token); weka.classifiers.evaluation.MarginCurve curve = new weka.classifiers.evaluation.MarginCurve(); Instances data = curve.getCurve(eval.predictions()); PlotData2D plot = new PlotData2D(data); plot.m_displayAllPoints = true; boolean[] connectPoints = new boolean[data.numInstances()]; for (int cp = 1; cp < connectPoints.length; cp++) connectPoints[cp] = true; plot.setConnectPoints(connectPoints); m_VisualizePanel.addPlot(plot); } catch (Exception e) { getLogger().log(Level.SEVERE, "Failed to display token: " + token, e); } } @Override public JComponent supplyComponent() { return m_VisualizePanel; } @Override public void clearPanel() { m_VisualizePanel.removeAllPlots(); } public void cleanUp() { m_VisualizePanel.removeAllPlots(); } }; if (token != null) result.display(token); return result; }