/** * Returns default capabilities of the classifier. * * @return the capabilities of this classifier */ @Override public Capabilities getCapabilities() { Capabilities result = super.getCapabilities(); result.disable(Capability.RELATIONAL_ATTRIBUTES); return result; }
/** * Gets the current settings of the Classifier. * * @return an array of strings suitable for passing to setOptions */ @Override public String[] getOptions() { Vector<String> result = new Vector<String>(); result.add("-M"); result.add("" + m_TransformMethod); Collections.addAll(result, super.getOptions()); return result.toArray(new String[result.size()]); }
@Override public Enumeration<Option> listOptions() { Vector<Option> options = new Vector<Option>(); options.add(new Option("\tPath to pre-constructed filter to use.", "load-filter", 1, "-load-filter <path to serialized pre-constructed filter>")); Enumeration superOpts = super.listOptions(); while (superOpts.hasMoreElements()) { options.add((Option) superOpts.nextElement()); } return options.elements(); }
/** * Parses a given list of options. Valid options are:<p> * * -W classname <br> * Specify the full class name of the base learner.<p> * * Options after -- are passed to the designated classifier.<p> * * @param options the list of options as an array of strings * @exception Exception if an option is not supported */ public void setOptions(String[] options) throws Exception { super.setOptions(options); String classifierName = Utils.getOption('W', options); if (classifierName.length() > 0) { setClassifier(AbstractClassifier.forName(classifierName, null)); setClassifier(AbstractClassifier.forName(classifierName, Utils.partitionOptions(options))); } else { setClassifier(AbstractClassifier.forName(defaultClassifierString(), null)); String[] classifierOptions = Utils.partitionOptions(options); if (classifierOptions.length > 0) { setClassifier(AbstractClassifier.forName(defaultClassifierString(), classifierOptions)); } else { setClassifier(AbstractClassifier.forName(defaultClassifierString(), defaultClassifierOptions())); } } }
/** * Returns an enumeration describing the available options. * * @return an enumeration of all the available options. */ public Enumeration<Option> listOptions() { Vector<Option> newVector = new Vector<Option>(3); newVector.addElement(new Option( "\tFull name of base classifier.\n" + "\t(default: " + defaultClassifierString() + ((defaultClassifierOptions().length > 0) ? " with options " + Utils.joinOptions(defaultClassifierOptions()) + ")" : ")"), "W", 1, "-W <classifier name>")); newVector.addAll(Collections.list(super.listOptions())); newVector.addElement(new Option( "", "", 0, "\nOptions specific to classifier " + m_Classifier.getClass().getName() + ":")); newVector.addAll(Collections.list(((OptionHandler)m_Classifier).listOptions())); return newVector.elements(); }
@Override public void setOptions(String[] options) throws Exception { setPathToPreConstructedFilter(Utils.getOption("load-filter", options)); super.setOptions(options); }
@Override public void postExecution() throws Exception { if (getClassifier() instanceof CommandlineRunnable) { ((CommandlineRunnable) getClassifier()).postExecution(); } } }
@Override public void setClassifier(Classifier newClassifier) { if (newClassifier instanceof MultiLabelClassifier) super.setClassifier(newClassifier); else System.err.println( "Base classifier must implement " + MultiLabelClassifier.class.getName() + ", provided: " + newClassifier.getClass().getName()); }
/** * Returns true if the base classifier implements BatchPredictor and is able * to generate batch predictions efficiently * * @return true if the base classifier can generate batch predictions * efficiently */ public boolean implementsMoreEfficientBatchPrediction() { if (!(getClassifier() instanceof BatchPredictor)) { return super.implementsMoreEfficientBatchPrediction(); } return ((BatchPredictor) getClassifier()).implementsMoreEfficientBatchPrediction(); }
/** * Gets the preferred batch size from the base learner if it implements * BatchPredictor. Returns 1 as the preferred batch size otherwise. * * @return the batch size to use */ public String getBatchSize() { if (getClassifier() instanceof BatchPredictor) { return ((BatchPredictor) getClassifier()).getBatchSize(); } else { return super.getBatchSize(); } }
/** * Parses a given list of options. Valid options are:<p> * * -W classname <br> * Specify the full class name of the base learner.<p> * * -I num <br> * Set the number of iterations (default 10). <p> * * -S num <br> * Set the random number seed (default 1). <p> * * Options after -- are passed to the designated classifier.<p> * * @param options the list of options as an array of strings * @exception Exception if an option is not supported */ public void setOptions(String[] options) throws Exception { String seed = Utils.getOption('S', options); if (seed.length() != 0) { setSeed(Integer.parseInt(seed)); } else { setSeed(1); } super.setOptions(options); }
/** * Parses a given list of options. Valid options are:<p> * * -W classname <br> * Specify the full class name of the base learner.<p> * * Options after -- are passed to the designated classifier.<p> * * @param options the list of options as an array of strings * @exception Exception if an option is not supported */ public void setOptions(String[] options) throws Exception { super.setOptions(options); String classifierName = Utils.getOption('W', options); if (classifierName.length() > 0) { setClassifier(AbstractClassifier.forName(classifierName, null)); setClassifier(AbstractClassifier.forName(classifierName, Utils.partitionOptions(options))); } else { setClassifier(AbstractClassifier.forName(defaultClassifierString(), null)); String[] classifierOptions = Utils.partitionOptions(options); if (classifierOptions.length > 0) { setClassifier(AbstractClassifier.forName(defaultClassifierString(), classifierOptions)); } else { setClassifier(AbstractClassifier.forName(defaultClassifierString(), defaultClassifierOptions())); } } }
@Override public void preExecution() throws Exception { if (getClassifier() instanceof CommandlineRunnable) { ((CommandlineRunnable) getClassifier()).preExecution(); } }
/** * Returns an enumeration describing the available options. * * @return an enumeration of all the available options. */ public Enumeration<Option> listOptions() { Vector<Option> newVector = new Vector<Option>(3); newVector.addElement(new Option( "\tFull name of base classifier.\n" + "\t(default: " + defaultClassifierString() + ((defaultClassifierOptions().length > 0) ? " with options " + Utils.joinOptions(defaultClassifierOptions()) + ")" : ")"), "W", 1, "-W <classifier name>")); newVector.addAll(Collections.list(super.listOptions())); newVector.addElement(new Option( "", "", 0, "\nOptions specific to classifier " + m_Classifier.getClass().getName() + ":")); newVector.addAll(Collections.list(((OptionHandler)m_Classifier).listOptions())); return newVector.elements(); }
@Override public void setClassifier(Classifier newClassifier) { if (newClassifier instanceof MultiLabelClassifier) super.setClassifier(newClassifier); else System.err.println( "Base classifier must implement " + MultiLabelClassifier.class.getName() + ", provided: " + newClassifier.getClass().getName()); }
/** * Returns true if the base classifier implements BatchPredictor and is able * to generate batch predictions efficiently * * @return true if the base classifier can generate batch predictions * efficiently */ public boolean implementsMoreEfficientBatchPrediction() { if (!(getClassifier() instanceof BatchPredictor)) { return super.implementsMoreEfficientBatchPrediction(); } return ((BatchPredictor) getClassifier()).implementsMoreEfficientBatchPrediction(); }
/** * Gets the preferred batch size from the base learner if it implements * BatchPredictor. Returns 1 as the preferred batch size otherwise. * * @return the batch size to use */ public String getBatchSize() { if (getClassifier() instanceof BatchPredictor) { return ((BatchPredictor) getClassifier()).getBatchSize(); } else { return super.getBatchSize(); } }
/** * Returns default capabilities of the classifier. * * @return the capabilities of this classifier */ @Override public Capabilities getCapabilities() { Capabilities result = super.getCapabilities(); result.disable(Capability.RELATIONAL_ATTRIBUTES); return result; }
/** * Gets the current settings of the classifier. * * @return an array of strings suitable for passing to setOptions */ public String [] getOptions() { Vector<String> options = new Vector<String>(); options.add("-S"); options.add("" + getSeed()); Collections.addAll(options, super.getOptions()); return options.toArray(new String[0]); }
/** * Parses a given list of options. Valid options are:<p> * * -W classname <br> * Specify the full class name of the base learner.<p> * * -I num <br> * Set the number of iterations (default 10). <p> * * -S num <br> * Set the random number seed (default 1). <p> * * Options after -- are passed to the designated classifier.<p> * * @param options the list of options as an array of strings * @exception Exception if an option is not supported */ public void setOptions(String[] options) throws Exception { String seed = Utils.getOption('S', options); if (seed.length() != 0) { setSeed(Integer.parseInt(seed)); } else { setSeed(1); } super.setOptions(options); }