From 831796dca7ba6f86971b8b9187d69a22cfc370a1 Mon Sep 17 00:00:00 2001 From: Aaron Keesing Date: Fri, 13 Oct 2023 20:47:06 +1300 Subject: [PATCH] Fix ERFH. Code cleanup and style. --- .../classifiers/multilabel/meta/ERFH.java | 20 +- .../classifiers/multilabel/meta/HOMER.java | 301 ++++++++---------- .../classifiers/multilabel/meta/MLRF.java | 103 +++--- 3 files changed, 209 insertions(+), 215 deletions(-) diff --git a/src/main/java/meka/classifiers/multilabel/meta/ERFH.java b/src/main/java/meka/classifiers/multilabel/meta/ERFH.java index a8b27447..bf1bbd05 100644 --- a/src/main/java/meka/classifiers/multilabel/meta/ERFH.java +++ b/src/main/java/meka/classifiers/multilabel/meta/ERFH.java @@ -38,6 +38,10 @@ public class ERFH extends MetaProblemTransformationMethod implements Randomizabl */ protected double threshold = 0.4; + public ERFH() { + this.m_Classifier = new BR(); + } + public static void main(String[] args) { ProblemTransformationMethod.runClassifier(new ERFH(), args); } @@ -51,7 +55,13 @@ public void setThreshold(double threshold) { } public String thresholdTipText() { - return "Prediction threshold for the multi-label classifier distribution."; + return "Prediction threshold"; + } + + @Override + protected String defaultClassifierString() { + // default classifier for CLI + return "meka.classifiers.multilabel.BR"; } /** @@ -88,11 +98,12 @@ public void buildClassifier(Instances D) throws Exception { // Modify i'th HOMER tree HOMER homer = new HOMER(); + homer.setDebug(getDebug()); homer.setClassifier(AbstractMultiLabelClassifier.makeCopy(m_Classifier)); homer.setLabelSplitter(new VariableKLabelSplitter(m_Seed + i)); homer.setSeed(m_Seed + i); if (getDebug()) - System.out.print(" " + i); + System.out.print(" " + i + ":\n"); m_Classifiers[i] = homer; m_Classifiers[i].buildClassifier(bag); } @@ -119,8 +130,8 @@ public String[] getOptions() { @Override public void setOptions(String[] options) throws Exception { + setThreshold(OptionUtils.parse(options, "T", 0.4)); super.setOptions(options); - threshold = OptionUtils.parse(options, "T", 0.4); } @Override @@ -128,7 +139,6 @@ public Enumeration