List of usage examples for weka.classifiers Evaluation predictions
public ArrayList<Prediction> predictions()
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).// www . j a v a 2 s . c o m * * @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 ww w . j ava 2 s . 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; }
From source file:adams.flow.sink.WekaThresholdCurve.java
License:Open Source License
/** * Plots the token (the panel and dialog have already been created at * this stage).//from w w w . ja va 2 s . c o m * * @param token the token to display */ @Override protected void display(Token token) { ThresholdCurve curve; Evaluation eval; PlotData2D plot; boolean[] connectPoints; int cp; Instances data; int[] indices; 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; } m_ClassLabelRange.setData(eval.getHeader().classAttribute()); indices = m_ClassLabelRange.getIntIndices(); for (int index : indices) { curve = new ThresholdCurve(); data = curve.getCurve(eval.predictions(), index); plot = new PlotData2D(data); plot.setPlotName(eval.getHeader().classAttribute().value(index)); 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); if (data.attribute(m_AttributeX.toDisplay()) != null) m_VisualizePanel.setXIndex(data.attribute(m_AttributeX.toDisplay()).index()); if (data.attribute(m_AttributeY.toDisplay()) != null) m_VisualizePanel.setYIndex(data.attribute(m_AttributeY.toDisplay()).index()); } } catch (Exception e) { handleException("Failed to display token: " + token, e); } }
From source file:adams.flow.sink.WekaThresholdCurve.java
License:Open Source License
/** * Creates a new panel for the token./*from w w w.j a va 2 s .c o m*/ * * @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 = "Threshold curve (" + getEvaluation(token).getHeader().relationName() + ")"; else name = "Threshold curve"; result = new AbstractComponentDisplayPanel(name) { private static final long serialVersionUID = -7362768698548152899L; protected ThresholdVisualizePanel m_VisualizePanel; @Override protected void initGUI() { super.initGUI(); setLayout(new BorderLayout()); m_VisualizePanel = new ThresholdVisualizePanel(); add(m_VisualizePanel, BorderLayout.CENTER); } @Override public void display(Token token) { try { Evaluation eval = getEvaluation(token); m_ClassLabelRange.setMax(eval.getHeader().classAttribute().numValues()); int[] indices = m_ClassLabelRange.getIntIndices(); for (int index : indices) { ThresholdCurve curve = new ThresholdCurve(); Instances data = curve.getCurve(eval.predictions(), index); PlotData2D plot = new PlotData2D(data); plot.setPlotName(eval.getHeader().classAttribute().value(index)); 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); if (data.attribute(m_AttributeX.toDisplay()) != null) m_VisualizePanel.setXIndex(data.attribute(m_AttributeX.toDisplay()).index()); if (data.attribute(m_AttributeY.toDisplay()) != null) m_VisualizePanel.setYIndex(data.attribute(m_AttributeY.toDisplay()).index()); } } 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; }
From source file:adams.flow.transformer.WekaAccumulatedError.java
License:Open Source License
/** * Executes the flow item.// w w w . j a v a 2s . c om * * @return null if everything is fine, otherwise error message */ @Override protected String doExecute() { String result; ArrayList predictions; int i; Evaluation eval; result = null; if (m_InputToken.getPayload() instanceof WekaEvaluationContainer) eval = (Evaluation) ((WekaEvaluationContainer) m_InputToken.getPayload()) .getValue(WekaEvaluationContainer.VALUE_EVALUATION); else eval = (Evaluation) m_InputToken.getPayload(); predictions = eval.predictions(); if (predictions != null) { m_NumPredictions = predictions.size(); for (i = 0; i < predictions.size(); i++) m_Predictions.add(new SortablePrediction((Prediction) predictions.get(i))); Collections.sort(m_Predictions); } else { getLogger().severe("No predictions available from Evaluation object!"); } return result; }
From source file:adams.flow.transformer.WekaBootstrapping.java
License:Open Source License
/** * Executes the flow item./*from ww w. j a va2s . c o m*/ * * @return null if everything is fine, otherwise error message */ @Override protected String doExecute() { String result; SpreadSheet sheet; Row row; Evaluation evalAll; Evaluation eval; WekaEvaluationContainer cont; TIntList indices; Random random; int i; int iteration; int size; List<Prediction> preds; Instances header; Instances data; ArrayList<Attribute> atts; Instance inst; boolean numeric; int classIndex; Double[] errors; Double[] errorsRev; Percentile<Double> perc; Percentile<Double> percRev; TIntList subset; result = null; if (m_InputToken.getPayload() instanceof Evaluation) { evalAll = (Evaluation) m_InputToken.getPayload(); } else { cont = (WekaEvaluationContainer) m_InputToken.getPayload(); evalAll = (Evaluation) cont.getValue(WekaEvaluationContainer.VALUE_EVALUATION); } if ((evalAll.predictions() == null) || (evalAll.predictions().size() == 0)) result = "No predictions available!"; if (result == null) { // init spreadsheet sheet = new DefaultSpreadSheet(); row = sheet.getHeaderRow(); row.addCell("S").setContentAsString("Subsample"); for (EvaluationStatistic s : m_StatisticValues) row.addCell(s.toString()).setContentAsString(s.toString()); for (i = 0; i < m_Percentiles.length; i++) { switch (m_ErrorCalculation) { case ACTUAL_MINUS_PREDICTED: row.addCell("perc-AmP-" + i).setContentAsString("Percentile-AmP-" + m_Percentiles[i]); break; case PREDICTED_MINUS_ACTUAL: row.addCell("perc-PmA-" + i).setContentAsString("Percentile-PmA-" + m_Percentiles[i]); break; case ABSOLUTE: row.addCell("perc-Abs-" + i).setContentAsString("Percentile-Abs-" + m_Percentiles[i]); break; case BOTH: row.addCell("perc-AmP-" + i).setContentAsString("Percentile-AmP-" + m_Percentiles[i]); row.addCell("perc-PmA-" + i).setContentAsString("Percentile-PmA-" + m_Percentiles[i]); break; default: throw new IllegalStateException("Unhandled error calculation: " + m_ErrorCalculation); } } // set up bootstrapping preds = evalAll.predictions(); random = new Random(m_Seed); indices = new TIntArrayList(); size = (int) Math.round(preds.size() * m_Percentage); header = evalAll.getHeader(); numeric = header.classAttribute().isNumeric(); m_ClassIndex.setData(header.classAttribute()); if (numeric) classIndex = -1; else classIndex = m_ClassIndex.getIntIndex(); for (i = 0; i < preds.size(); i++) indices.add(i); // create fake evalutions subset = new TIntArrayList(); for (iteration = 0; iteration < m_NumSubSamples; iteration++) { if (isStopped()) { sheet = null; break; } // determine subset.clear(); if (m_WithReplacement) { for (i = 0; i < size; i++) subset.add(indices.get(random.nextInt(preds.size()))); } else { indices.shuffle(random); for (i = 0; i < size; i++) subset.add(indices.get(i)); } // create dataset from predictions errors = new Double[size]; errorsRev = new Double[size]; atts = new ArrayList<>(); atts.add(header.classAttribute().copy("Actual")); data = new Instances(header.relationName() + "-" + (iteration + 1), atts, size); data.setClassIndex(0); for (i = 0; i < subset.size(); i++) { inst = new DenseInstance(preds.get(subset.get(i)).weight(), new double[] { preds.get(subset.get(i)).actual() }); data.add(inst); switch (m_ErrorCalculation) { case ACTUAL_MINUS_PREDICTED: errors[i] = preds.get(subset.get(i)).actual() - preds.get(subset.get(i)).predicted(); break; case PREDICTED_MINUS_ACTUAL: errorsRev[i] = preds.get(subset.get(i)).predicted() - preds.get(subset.get(i)).actual(); break; case ABSOLUTE: errors[i] = Math .abs(preds.get(subset.get(i)).actual() - preds.get(subset.get(i)).predicted()); break; case BOTH: errors[i] = preds.get(subset.get(i)).actual() - preds.get(subset.get(i)).predicted(); errorsRev[i] = preds.get(subset.get(i)).predicted() - preds.get(subset.get(i)).actual(); break; default: throw new IllegalStateException("Unhandled error calculation: " + m_ErrorCalculation); } } // perform "fake" evaluation try { eval = new Evaluation(data); for (i = 0; i < subset.size(); i++) { if (numeric) eval.evaluateModelOnceAndRecordPrediction( new double[] { preds.get(subset.get(i)).predicted() }, data.instance(i)); else eval.evaluateModelOnceAndRecordPrediction( ((NominalPrediction) preds.get(subset.get(i))).distribution().clone(), data.instance(i)); } } catch (Exception e) { result = handleException( "Failed to create 'fake' Evaluation object (iteration: " + (iteration + 1) + ")!", e); break; } // add row row = sheet.addRow(); row.addCell("S").setContent(iteration + 1); for (EvaluationStatistic s : m_StatisticValues) { try { row.addCell(s.toString()).setContent(EvaluationHelper.getValue(eval, s, classIndex)); } catch (Exception e) { getLogger().log(Level.SEVERE, "Failed to calculate statistic in iteration #" + (iteration + 1) + ": " + s, e); row.addCell(s.toString()).setMissing(); } } for (i = 0; i < m_Percentiles.length; i++) { perc = new Percentile<>(); perc.addAll(errors); percRev = new Percentile<>(); percRev.addAll(errorsRev); switch (m_ErrorCalculation) { case ACTUAL_MINUS_PREDICTED: row.addCell("perc-AmP-" + i).setContent(perc.getPercentile(m_Percentiles[i].doubleValue())); break; case PREDICTED_MINUS_ACTUAL: row.addCell("perc-PmA-" + i) .setContent(percRev.getPercentile(m_Percentiles[i].doubleValue())); break; case ABSOLUTE: row.addCell("perc-Abs-" + i).setContent(perc.getPercentile(m_Percentiles[i].doubleValue())); break; case BOTH: row.addCell("perc-AmP-" + i).setContent(perc.getPercentile(m_Percentiles[i].doubleValue())); row.addCell("perc-PmA-" + i) .setContent(percRev.getPercentile(m_Percentiles[i].doubleValue())); break; default: throw new IllegalStateException("Unhandled error calculation: " + m_ErrorCalculation); } } } if ((result == null) && (sheet != null)) m_OutputToken = new Token(sheet); } return result; }
From source file:adams.flow.transformer.WekaEvaluationInfo.java
License:Open Source License
/** * Executes the flow item./*w ww . ja v a2s. c om*/ * * @return null if everything is fine, otherwise error message */ @Override protected String doExecute() { Evaluation eval; if (m_InputToken.getPayload() instanceof Evaluation) eval = (Evaluation) m_InputToken.getPayload(); else eval = (Evaluation) ((WekaEvaluationContainer) m_InputToken.getPayload()) .getValue(WekaEvaluationContainer.VALUE_EVALUATION); switch (m_Type) { case RELATION_NAME: m_OutputToken = new Token(eval.getHeader().relationName()); break; case CLASS_ATTRIBUTE_NAME: m_OutputToken = new Token(eval.getHeader().classAttribute().name()); break; case HEADER: m_OutputToken = new Token(eval.getHeader()); break; case PREDICTIONS_RECORDED: m_OutputToken = new Token(eval.predictions() != null); break; case NUM_PREDICTIONS: if (eval.predictions() == null) m_OutputToken = new Token(-1); else m_OutputToken = new Token(eval.predictions().size()); break; default: throw new IllegalStateException("Unhandled info type: " + m_Type); } return null; }
From source file:adams.flow.transformer.WekaPredictionsToInstances.java
License:Open Source License
/** * Executes the flow item./* ww w.java 2s .c om*/ * * @return null if everything is fine, otherwise error message */ @Override protected String doExecute() { String result; Evaluation eval; int i; int n; int indexErr; int indexProb; int indexDist; int indexWeight; boolean nominal; Instances header; ArrayList<Attribute> atts; ArrayList<String> values; ArrayList<Prediction> predictions; Prediction pred; double[] vals; Instances data; Instances testData; int[] indices; result = null; if (m_InputToken.getPayload() instanceof WekaEvaluationContainer) { eval = (Evaluation) ((WekaEvaluationContainer) m_InputToken.getPayload()) .getValue(WekaEvaluationContainer.VALUE_EVALUATION); indices = (int[]) ((WekaEvaluationContainer) m_InputToken.getPayload()) .getValue(WekaEvaluationContainer.VALUE_ORIGINALINDICES); testData = (Instances) ((WekaEvaluationContainer) m_InputToken.getPayload()) .getValue(WekaEvaluationContainer.VALUE_TESTDATA); } else { eval = (Evaluation) m_InputToken.getPayload(); indices = null; testData = null; } header = eval.getHeader(); nominal = header.classAttribute().isNominal(); predictions = eval.predictions(); if (predictions != null) { // create header atts = new ArrayList<>(); // actual if (nominal && m_AddLabelIndex) { values = new ArrayList<>(); for (i = 0; i < header.classAttribute().numValues(); i++) values.add((i + 1) + ":" + header.classAttribute().value(i)); atts.add(new Attribute(m_MeasuresPrefix + "Actual", values)); } else { atts.add(header.classAttribute().copy(m_MeasuresPrefix + "Actual")); } // predicted if (nominal && m_AddLabelIndex) { values = new ArrayList<>(); for (i = 0; i < header.classAttribute().numValues(); i++) values.add((i + 1) + ":" + header.classAttribute().value(i)); atts.add(new Attribute(m_MeasuresPrefix + "Predicted", values)); } else { atts.add(header.classAttribute().copy(m_MeasuresPrefix + "Predicted")); } // error indexErr = -1; if (m_ShowError) { indexErr = atts.size(); if (nominal) { values = new ArrayList<>(); values.add("n"); values.add("y"); atts.add(new Attribute(m_MeasuresPrefix + "Error", values)); } else { atts.add(new Attribute(m_MeasuresPrefix + "Error")); } } // probability indexProb = -1; if (m_ShowProbability && nominal) { indexProb = atts.size(); atts.add(new Attribute(m_MeasuresPrefix + "Probability")); } // distribution indexDist = -1; if (m_ShowDistribution && nominal) { indexDist = atts.size(); for (n = 0; n < header.classAttribute().numValues(); n++) atts.add(new Attribute( m_MeasuresPrefix + "Distribution (" + header.classAttribute().value(n) + ")")); } // weight indexWeight = -1; if (m_ShowWeight) { indexWeight = atts.size(); atts.add(new Attribute(m_MeasuresPrefix + "Weight")); } data = new Instances("Predictions", atts, predictions.size()); data.setClassIndex(1); // predicted // add data if ((indices != null) && m_UseOriginalIndices) predictions = CrossValidationHelper.alignPredictions(predictions, indices); for (i = 0; i < predictions.size(); i++) { pred = predictions.get(i); vals = new double[data.numAttributes()]; // actual vals[0] = pred.actual(); // predicted vals[1] = pred.predicted(); // error if (m_ShowError) { if (nominal) { vals[indexErr] = ((pred.actual() != pred.predicted()) ? 1.0 : 0.0); } else { if (m_UseAbsoluteError) vals[indexErr] = Math.abs(pred.actual() - pred.predicted()); else vals[indexErr] = pred.actual() - pred.predicted(); } } // probability if (m_ShowProbability && nominal) { vals[indexProb] = StatUtils.max(((NominalPrediction) pred).distribution()); } // distribution if (m_ShowDistribution && nominal) { for (n = 0; n < header.classAttribute().numValues(); n++) vals[indexDist + n] = ((NominalPrediction) pred).distribution()[n]; } // weight if (m_ShowWeight) { vals[indexWeight] = pred.weight(); } // add row data.add(new DenseInstance(1.0, vals)); } // add test data? if ((testData != null) && !m_TestAttributes.isEmpty()) { testData = filterTestData(testData); if (testData != null) data = Instances.mergeInstances(data, testData); } // generate output token m_OutputToken = new Token(data); } else { getLogger().severe("No predictions available from Evaluation object!"); } return result; }
From source file:adams.flow.transformer.WekaPredictionsToSpreadSheet.java
License:Open Source License
/** * Executes the flow item.//from w w w. j a va2s.co m * * @return null if everything is fine, otherwise error message */ @Override protected String doExecute() { String result; Evaluation eval; int i; int n; int indexErr; int indexProb; int indexDist; int indexWeight; boolean nominal; Instances header; ArrayList<Prediction> predictions; Prediction pred; SpreadSheet data; Instances testData; InstancesView testView; Row row; int[] indices; result = null; if (m_InputToken.getPayload() instanceof WekaEvaluationContainer) { eval = (Evaluation) ((WekaEvaluationContainer) m_InputToken.getPayload()) .getValue(WekaEvaluationContainer.VALUE_EVALUATION); indices = (int[]) ((WekaEvaluationContainer) m_InputToken.getPayload()) .getValue(WekaEvaluationContainer.VALUE_ORIGINALINDICES); testData = (Instances) ((WekaEvaluationContainer) m_InputToken.getPayload()) .getValue(WekaEvaluationContainer.VALUE_TESTDATA); } else { eval = (Evaluation) m_InputToken.getPayload(); indices = null; testData = null; } header = eval.getHeader(); nominal = header.classAttribute().isNominal(); predictions = eval.predictions(); if (predictions != null) { data = new DefaultSpreadSheet(); data.setName("Predictions"); // create header row = data.getHeaderRow(); row.addCell("A").setContent(m_MeasuresPrefix + "Actual"); row.addCell("P").setContent(m_MeasuresPrefix + "Predicted"); indexErr = -1; if (m_ShowError) { indexErr = row.getCellCount(); row.addCell("E").setContent(m_MeasuresPrefix + "Error"); } // probability indexProb = -1; if (m_ShowProbability && nominal) { indexProb = row.getCellCount(); row.addCell("Pr").setContent(m_MeasuresPrefix + "Probability"); } // distribution indexDist = -1; if (m_ShowDistribution && nominal) { indexDist = row.getCellCount(); for (n = 0; n < header.classAttribute().numValues(); n++) row.addCell("D" + n).setContent( m_MeasuresPrefix + "Distribution (" + header.classAttribute().value(n) + ")"); } // weight indexWeight = -1; if (m_ShowWeight) { indexWeight = row.getCellCount(); row.addCell("W").setContent(m_MeasuresPrefix + "Weight"); } // add data if ((indices != null) && m_UseOriginalIndices) predictions = CrossValidationHelper.alignPredictions(predictions, indices); for (i = 0; i < predictions.size(); i++) { pred = predictions.get(i); row = data.addRow(); // actual if (Double.isNaN(pred.actual())) row.addCell(0).setMissing(); else if (nominal) row.addCell(0).setContentAsString(header.classAttribute().value((int) pred.actual())); else row.addCell(0).setContent(pred.actual()); // predicted if (Double.isNaN(pred.predicted())) row.addCell(1).setMissing(); else if (nominal) row.addCell(1).setContentAsString(header.classAttribute().value((int) pred.predicted())); else row.addCell(1).setContent(pred.predicted()); // error if (m_ShowError) { if (nominal) { row.addCell(indexErr).setContent((pred.actual() != pred.predicted() ? "true" : "false")); } else { if (m_UseAbsoluteError) row.addCell(indexErr).setContent(Math.abs(pred.actual() - pred.predicted())); else row.addCell(indexErr).setContent(pred.actual() - pred.predicted()); } } // probability if (m_ShowProbability && nominal) { row.addCell(indexProb).setContent(StatUtils.max(((NominalPrediction) pred).distribution())); } // distribution if (m_ShowDistribution && nominal) { for (n = 0; n < header.classAttribute().numValues(); n++) row.addCell(indexDist + n).setContent(((NominalPrediction) pred).distribution()[n]); } // weight if (m_ShowWeight) { row.addCell(indexWeight).setContent(pred.weight()); } } // add test data? if ((testData != null) && !m_TestAttributes.isEmpty()) { testData = filterTestData(testData); if (testData != null) { testView = new InstancesView(testData); data.mergeWith(testView); } } // generate output token m_OutputToken = new Token(data); } else { getLogger().severe("No predictions available from Evaluation object!"); } return result; }
From source file:adams.gui.visualization.debug.inspectionhandler.WekaEvaluation.java
License:Open Source License
/** * Returns further inspection values.//w w w . j a v a 2 s . co m * * @param obj the object to further inspect * @return the named inspected values */ @Override public Hashtable<String, Object> inspect(Object obj) { Hashtable<String, Object> result; Evaluation eval; WekaEvaluationValues values; boolean numeric; boolean nominal; List<EvaluationStatistic> stats; String msg; Token token; result = new Hashtable<>(); eval = (Evaluation) obj; result.put("header", eval.getHeader()); result.put("predictions", eval.predictions()); nominal = eval.getHeader().classAttribute().isNominal(); numeric = eval.getHeader().classAttribute().isNumeric(); stats = new ArrayList<>(); for (EvaluationStatistic stat : EvaluationStatistic.values()) { if (nominal && stat.isOnlyNominal()) stats.add(stat); else if (numeric && stat.isOnlyNumeric()) stats.add(stat); else if (!stat.isOnlyNumeric() && !stat.isOnlyNominal()) stats.add(stat); } values = new WekaEvaluationValues(); values.setStatisticValues(stats.toArray(new EvaluationStatistic[stats.size()])); values.input(new Token(eval)); msg = values.execute(); if (msg == null) { token = values.output(); if (token != null) result.put("statistics", token.getPayload()); } else { System.err.println(getClass().getName() + ": Failed to extract statistics:\n" + msg); } return result; }