AttributeSelectedClassifier temp = new AttributeSelectedClassifier(); temp.setClassifier(base); temp.setEvaluator(eval); classifier = temp;
/** * 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(); }
/** * Returns graph describing the classifier (if possible). * * @return the graph of the classifier in dotty format * @throws Exception if the classifier cannot be graphed */ public String graph() throws Exception { if (m_Classifier instanceof Drawable) return ((Drawable)m_Classifier).graph(); else throw new Exception("Classifier: " + getClassifierSpec() + " cannot be graphed"); }
/** * Main method for testing this class. * * @param argv should contain the following arguments: * -t training file [-T test file] [-c class index] */ public static void main(String [] argv) { runClassifier(new AttributeSelectedClassifier(), argv); } }
/** * 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>(); // same attribute evaluator options.add("-E"); options.add("" +getEvaluatorSpec()); // same for search options.add("-S"); options.add("" + getSearchSpec()); Collections.addAll(options, super.getOptions()); return options.toArray(new String[0]); }
new weka.classifiers.meta.AttributeSelectedClassifier(); cls .setEvaluator((ASEvaluation) m_AttributeEvaluatorEditor.getValue()); cls.setSearch((ASSearch) m_AttributeSearchEditor.getValue()); cmdClassifier = cls.getClass().getName() + " " + Utils.joinOptions(cls.getOptions());
/** Creates a default AttributeSelectedClassifier */ public Classifier getClassifier() { return new AttributeSelectedClassifier(); }
setEvaluator(ASEvaluation.forName(evaluatorName, evaluatorSpec)); setSearch(ASSearch.forName(searchName, searchSpec));
throws Exception { if (getClassifier() instanceof BatchPredictor) { Instances newInstances; if (m_AttributeSelection == null) { "FilteredClassifier: filter has returned more/less instances than required."); return ((BatchPredictor) getClassifier()).distributionsForInstances(newInstances); } else { double[][] result = new double[insts.numInstances()][insts.numClasses()]; for (int i = 0; i < insts.numInstances(); i++) { result[i] = distributionForInstance(insts.instance(i));
if (getEvaluator() instanceof OptionHandler) { newVector.addElement(new Option( "", "", 0, "\nOptions specific to attribute evaluator " + getEvaluator().getClass().getName() + ":")); newVector.addAll(Collections.list(((OptionHandler)getEvaluator()).listOptions())); if (getSearch() instanceof OptionHandler) { newVector.addElement(new Option( "", "", 0, "\nOptions specific to search method " + getSearch().getClass().getName() + ":")); newVector.addAll(Collections.list(((OptionHandler)getSearch()).listOptions()));
/** * Gets the evaluator specification string, which contains the class name of * the attribute evaluator and any options to it * * @return the evaluator string. */ protected String getEvaluatorSpec() { ASEvaluation e = getEvaluator(); if (e instanceof OptionHandler) { return e.getClass().getName() + " " + Utils.joinOptions(((OptionHandler)e).getOptions()); } return e.getClass().getName(); }
/** * Gets the search specification string, which contains the class name of * the search method and any options to it * * @return the search string. */ protected String getSearchSpec() { ASSearch s = getSearch(); if (s instanceof OptionHandler) { return s.getClass().getName() + " " + Utils.joinOptions(((OptionHandler)s).getOptions()); } return s.getClass().getName(); }
getCapabilities().testWithFail(data);
new weka.classifiers.meta.AttributeSelectedClassifier(); cls .setEvaluator((ASEvaluation) m_AttributeEvaluatorEditor.getValue()); cls.setSearch((ASSearch) m_AttributeSearchEditor.getValue()); cmdClassifier = cls.getClass().getName() + " " + Utils.joinOptions(cls.getOptions());
/** * Main method for testing this class. * * @param argv should contain the following arguments: * -t training file [-T test file] [-c class index] */ public static void main(String [] argv) { runClassifier(new AttributeSelectedClassifier(), argv); } }
/** Creates a default AttributeSelectedClassifier */ public Classifier getClassifier() { return new AttributeSelectedClassifier(); }
setEvaluator(ASEvaluation.forName(evaluatorName, evaluatorSpec)); setSearch(ASSearch.forName(searchName, searchSpec));
/** * 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>(); // same attribute evaluator options.add("-E"); options.add("" +getEvaluatorSpec()); // same for search options.add("-S"); options.add("" + getSearchSpec()); Collections.addAll(options, super.getOptions()); return options.toArray(new String[0]); }
throws Exception { if (getClassifier() instanceof BatchPredictor) { Instances newInstances; if (m_AttributeSelection == null) { "FilteredClassifier: filter has returned more/less instances than required."); return ((BatchPredictor) getClassifier()).distributionsForInstances(newInstances); } else { double[][] result = new double[insts.numInstances()][insts.numClasses()]; for (int i = 0; i < insts.numInstances(); i++) { result[i] = distributionForInstance(insts.instance(i));
if (getEvaluator() instanceof OptionHandler) { newVector.addElement(new Option( "", "", 0, "\nOptions specific to attribute evaluator " + getEvaluator().getClass().getName() + ":")); newVector.addAll(Collections.list(((OptionHandler)getEvaluator()).listOptions())); if (getSearch() instanceof OptionHandler) { newVector.addElement(new Option( "", "", 0, "\nOptions specific to search method " + getSearch().getClass().getName() + ":")); newVector.addAll(Collections.list(((OptionHandler)getSearch()).listOptions()));