Ranker ranker = new Ranker(); InfoGainAttributeEval ig = new InfoGainAttributeEval(); Instances instances = SamplesManager.asWekaInstances(trainSet); ig.buildEvaluator(instances); firstAttributes = ranker.search(ig,instances); candidates = Arrays.copyOfRange(firstAttributes, 0, FIRST_SIZE_REDUCTION); instances = reduceDimenstions(instances, candidates) PrincipalComponents pca = new PrincipalComponents(); pca.setVarianceCovered(var); ranker = new Ranker(); ranker.setNumToSelect(numFeatures); selection = new AttributeSelection(); selection.setEvaluator(pca); selection.setSearch(ranker); selection.SelectAttributes(instances ); instances = selection.reduceDimensionality(wekaInstances);
/** * set the search method * * @param search the search method to use */ public void setSearch(ASSearch search) { m_searchMethod = search; if (m_searchMethod instanceof RankedOutputSearch) { setRanking(((RankedOutputSearch) m_searchMethod).getGenerateRanking()); } }
/** * Main method for executing this class. * * @param args the options */ public static void main(String[] args) { runEvaluator(new ClassifierAttributeEval(), args); } }
/** * set options to their default values */ protected void resetOptions() { m_trainSelector = new weka.attributeSelection.AttributeSelection(); setEvaluator(new CfsSubsetEval()); setSearch(new BestFirst()); m_SelectedAttributes = null; }
/** * configures the CheckAttributeSelection instance used throughout the tests * * @return the fully configured CheckAttributeSelection instance used for testing */ protected CheckAttributeSelection getTester() { CheckAttributeSelection result; result = super.getTester(); result.setTestEvaluator(false); return result; }
/** * tests whether the scheme declares a serialVersionUID. */ public void testSerialVersionUID() { boolean[] result; result = m_Tester.declaresSerialVersionUID(); if (!result[0]) fail("Doesn't declare serialVersionUID!"); }
/** * Return the number of attributes selected from the most recent run of * attribute selection * * @return the number of attributes selected */ public int numberAttributesSelected() throws Exception { int[] att = selectedAttributes(); return att.length - 1; }
/** * Set the value of the threshold for repeating cross validation * * @param t the value of the threshold */ public void setThreshold(double t) { m_wrapperTemplate.setThreshold(t); }
/** * Set the class value (label or index) to use with IR metric evaluation of * subsets. Leaving this unset will result in the class weighted average for * the IR metric being used. * * @param val the class label or 1-based index of the class label to use when * evaluating subsets with an IR metric */ public void setIRClassValue(String val) { m_wrapperTemplate.setIRClassValue(val); }
/** * Get the number of folds used for accuracy estimation * * @return the number of folds */ public int getFolds() { return m_wrapperTemplate.getFolds(); }
/** * Constructor */ public InfoGainAttributeEval() { resetOptions(); }
/** * returns a string for the class type * * @param type the class type * @return the class type as string */ protected String getClassTypeString(int type) { return CheckAttributeSelection.attributeTypeToString(type); }
/** * Constructor */ public ExhaustiveSearch() { resetOptions(); }
/** * Constructor. Make a new GeneticSearch object */ public GeneticSearch() { resetOptions(); }
/** * set options to their default values */ protected void resetOptions() { m_trainSelector = new weka.attributeSelection.AttributeSelection(); setEvaluator(new CfsSubsetEval()); setSearch(new BestFirst()); m_SelectedAttributes = null; }
/** * configures the CheckAttributeSelection instance used throughout the tests * * @return the fully configured CheckAttributeSelection instance used for testing */ protected CheckAttributeSelection getTester() { CheckAttributeSelection result; result = super.getTester(); result.setTestEvaluator(true); return result; }
/** * tests whether the scheme declares a serialVersionUID. */ public void testSerialVersionUID() { boolean[] result; result = m_Tester.declaresSerialVersionUID(); if (!result[0]) fail("Doesn't declare serialVersionUID!"); }
/** * set the search method * * @param search the search method to use */ public void setSearch(ASSearch search) { m_searchMethod = search; if (m_searchMethod instanceof RankedOutputSearch) { setRanking(((RankedOutputSearch) m_searchMethod).getGenerateRanking()); } }
/** * configures the CheckAttributeSelection instance used throughout the tests * * @return the fully configured CheckAttributeSelection instance used for testing */ protected CheckAttributeSelection getTester() { CheckAttributeSelection result; result = super.getTester(); result.setTestEvaluator(false); return result; }
/** * configures the CheckAttributeSelection instance used throughout the tests * * @return the fully configured CheckAttributeSelection instance used for testing */ protected CheckAttributeSelection getTester() { CheckAttributeSelection result; result = super.getTester(); result.setTestEvaluator(true); return result; }