/** * Get a list of all available evaluation metric names * * @return a list of all available evaluation metric names */ public static List<String> getAllMetricNames() { List<String> metrics = getBuiltInMetricNames(); metrics.addAll(getPluginMetricNames()); return metrics; }
/** * Sets the Evaluation object to use * * @param eval the Evaluation object to use */ public void setEvaluation(Evaluation eval) { m_eval = eval; initializeWithPluginMetrics(); }
EvaluationMetricHelper helper = new EvaluationMetricHelper(eval); boolean maximise = helper.metricIsMaximisable(m_evalMetric); if (maximise) { m_bestResult = Double.MIN_VALUE; helper.setEvaluation(eval); for (int r = 0; r < numRuns; r++) { for (int i = 0; i < numFolds; i++) { helper.getNamedMetric(m_evalMetric, getClassValueIndex()) : helper.getNamedMetric(m_evalMetric); tempThresholds = helper.getNamedMetricThresholds(m_evalMetric); } else { for (int i = 0; i < numFolds; i++) { eval = new Evaluation(trainingSets[r][i]); helper.setEvaluation(eval); eval.evaluateModel(classifiers[r][i], testSets[r][i]); result += getClassValueIndex() >= 0 ? helper.getNamedMetric(m_evalMetric, getClassValueIndex()) : helper.getNamedMetric(m_evalMetric); double[] thresholds = helper.getNamedMetricThresholds(m_evalMetric);
/** * Returns true if the named metric is maximisable * * @param statName the name of the metric/statistic to check * @return true if the metric in question is optimum at a maximal value * @throws Exception if a problem occurs */ public boolean metricIsMaximisable(String statName) throws Exception { Integer builtinIndex = m_builtin.get(statName.toLowerCase()); if (builtinIndex != null) { return builtInMetricIsMaximisable(builtinIndex.intValue()); } else { AbstractEvaluationMetric m = m_pluginMetrics.get(statName.toLowerCase()); if (m == null) { throw new Exception("Unknown evaluation metric: " + statName); } return pluginMetricIsMaximisable(m, statName); } } }
/** * Gets the value of a named metric. For information retrieval metrics if a * class value index is not supplied then the class weighted variant is * returned. * * @param statName the name of the metric/statistic to get * @param classValIndex the optional class value index * @return the value of the metric * @throws Exception if the metric/stat is unknown or a problem occurs */ public double getNamedMetric(String statName, int... classValIndex) throws Exception { if (classValIndex != null && classValIndex.length > 1) { throw new IllegalArgumentException( "Only one class value index should be supplied"); } Integer builtinIndex = m_builtin.get(statName.toLowerCase()); if (builtinIndex != null) { return getBuiltinMetricValue(builtinIndex.intValue(), classValIndex); } else { AbstractEvaluationMetric m = m_pluginMetrics.get(statName.toLowerCase()); if (m == null) { throw new Exception("Unknown evaluation metric: " + statName); } return getPluginMetricValue(m, statName, classValIndex); } }
"-W")); List<String> metrics = EvaluationMetricHelper.getAllMetricNames(); StringBuilder b = new StringBuilder(); int length = 0;
EvaluationMetricHelper helper = new EvaluationMetricHelper(eval); boolean maximise = helper.metricIsMaximisable(m_evalMetric); if (maximise) { m_bestResult = Double.MIN_VALUE; helper.setEvaluation(eval); for (int r = 0; r < numRuns; r++) { for (int i = 0; i < numFolds; i++) { helper.getNamedMetric(m_evalMetric, getClassValueIndex()) : helper.getNamedMetric(m_evalMetric); tempThresholds = helper.getNamedMetricThresholds(m_evalMetric); } else { for (int i = 0; i < numFolds; i++) { eval = new Evaluation(trainingSets[r][i]); helper.setEvaluation(eval); eval.evaluateModel(classifiers[r][i], testSets[r][i]); result += getClassValueIndex() >= 0 ? helper.getNamedMetric(m_evalMetric, getClassValueIndex()) : helper.getNamedMetric(m_evalMetric); double[] thresholds = helper.getNamedMetricThresholds(m_evalMetric);
/** * Returns true if the named metric is maximisable * * @param statName the name of the metric/statistic to check * @return true if the metric in question is optimum at a maximal value * @throws Exception if a problem occurs */ public boolean metricIsMaximisable(String statName) throws Exception { Integer builtinIndex = m_builtin.get(statName.toLowerCase()); if (builtinIndex != null) { return builtInMetricIsMaximisable(builtinIndex.intValue()); } else { AbstractEvaluationMetric m = m_pluginMetrics.get(statName.toLowerCase()); if (m == null) { throw new Exception("Unknown evaluation metric: " + statName); } return pluginMetricIsMaximisable(m, statName); } } }
/** * Gets the value of a named metric. For information retrieval metrics if a * class value index is not supplied then the class weighted variant is * returned. * * @param statName the name of the metric/statistic to get * @param classValIndex the optional class value index * @return the value of the metric * @throws Exception if the metric/stat is unknown or a problem occurs */ public double getNamedMetric(String statName, int... classValIndex) throws Exception { if (classValIndex != null && classValIndex.length > 1) { throw new IllegalArgumentException( "Only one class value index should be supplied"); } Integer builtinIndex = m_builtin.get(statName.toLowerCase()); if (builtinIndex != null) { return getBuiltinMetricValue(builtinIndex.intValue(), classValIndex); } else { AbstractEvaluationMetric m = m_pluginMetrics.get(statName.toLowerCase()); if (m == null) { throw new Exception("Unknown evaluation metric: " + statName); } return getPluginMetricValue(m, statName, classValIndex); } }
"-W")); List<String> metrics = EvaluationMetricHelper.getAllMetricNames(); StringBuilder b = new StringBuilder(); int length = 0;
/** * Get a list of all available evaluation metric names * * @return a list of all available evaluation metric names */ public static List<String> getAllMetricNames() { List<String> metrics = getBuiltInMetricNames(); metrics.addAll(getPluginMetricNames()); return metrics; }
/** * Sets the Evaluation object to use * * @param eval the Evaluation object to use */ public void setEvaluation(Evaluation eval) { m_eval = eval; initializeWithPluginMetrics(); }