weka.attributeSelection.BestFirst Java Examples
The following examples show how to use
weka.attributeSelection.BestFirst.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AttributeSelection.java From tsml with GNU General Public License v3.0 | 5 votes |
/** * set options to their default values */ protected void resetOptions() { m_trainSelector = new weka.attributeSelection.AttributeSelection(); setEvaluator(new CfsSubsetEval()); setSearch(new BestFirst()); m_SelectedAttributes = null; m_FilterOptions = null; }
Example #2
Source File: WekaFeatureSelectionTest.java From Java-Data-Science-Cookbook with MIT License | 5 votes |
public void selectFeatures(){ AttributeSelection attSelection = new AttributeSelection(); CfsSubsetEval eval = new CfsSubsetEval(); BestFirst search = new BestFirst(); attSelection.setEvaluator(eval); attSelection.setSearch(search); try { attSelection.SelectAttributes(iris); int[] attIndex = attSelection.selectedAttributes(); System.out.println(Utils.arrayToString(attIndex)); } catch (Exception e) { } }
Example #3
Source File: WekaFeatureSelectionTest.java From Java-Data-Science-Cookbook with MIT License | 5 votes |
public void selectFeaturesWithFilter(){ weka.filters.supervised.attribute.AttributeSelection filter = new weka.filters.supervised.attribute.AttributeSelection(); CfsSubsetEval eval = new CfsSubsetEval(); BestFirst search = new BestFirst(); filter.setEvaluator(eval); filter.setSearch(search); try { filter.setInputFormat(iris); Instances newData = Filter.useFilter(iris, filter); System.out.println(newData); } catch (Exception e) { } }
Example #4
Source File: DecisionTable.java From tsml with GNU General Public License v3.0 | 2 votes |
/** * Parses the options for this object. <p/> * <!-- options-start --> * Valid options are: <p/> * * <pre> -S <search method specification> * Full class name of search method, followed * by its options. * eg: "weka.attributeSelection.BestFirst -D 1" * (default weka.attributeSelection.BestFirst)</pre> * * <pre> -X <number of folds> * Use cross validation to evaluate features. * Use number of folds = 1 for leave one out CV. * (Default = leave one out CV)</pre> * * <pre> -E <acc | rmse | mae | auc> * Performance evaluation measure to use for selecting attributes. * (Default = accuracy for discrete class and rmse for numeric class)</pre> * * <pre> -I * Use nearest neighbour instead of global table majority.</pre> * * <pre> -R * Display decision table rules. * </pre> * * <pre> * Options specific to search method weka.attributeSelection.BestFirst: * </pre> * * <pre> -P <start set> * Specify a starting set of attributes. * Eg. 1,3,5-7.</pre> * * <pre> -D <0 = backward | 1 = forward | 2 = bi-directional> * Direction of search. (default = 1).</pre> * * <pre> -N <num> * Number of non-improving nodes to * consider before terminating search.</pre> * * <pre> -S <num> * Size of lookup cache for evaluated subsets. * Expressed as a multiple of the number of * attributes in the data set. (default = 1)</pre> * <!-- options-end --> * * @param options the list of options as an array of strings * @throws Exception if an option is not supported */ public void setOptions(String[] options) throws Exception { String optionString; resetOptions(); optionString = Utils.getOption('X',options); if (optionString.length() != 0) { m_CVFolds = Integer.parseInt(optionString); } m_useIBk = Utils.getFlag('I',options); m_displayRules = Utils.getFlag('R',options); optionString = Utils.getOption('E', options); if (optionString.length() != 0) { if (optionString.equals("acc")) { setEvaluationMeasure(new SelectedTag(EVAL_ACCURACY, TAGS_EVALUATION)); } else if (optionString.equals("rmse")) { setEvaluationMeasure(new SelectedTag(EVAL_RMSE, TAGS_EVALUATION)); } else if (optionString.equals("mae")) { setEvaluationMeasure(new SelectedTag(EVAL_MAE, TAGS_EVALUATION)); } else if (optionString.equals("auc")) { setEvaluationMeasure(new SelectedTag(EVAL_AUC, TAGS_EVALUATION)); } else { throw new IllegalArgumentException("Invalid evaluation measure"); } } String searchString = Utils.getOption('S', options); if (searchString.length() == 0) searchString = weka.attributeSelection.BestFirst.class.getName(); String [] searchSpec = Utils.splitOptions(searchString); if (searchSpec.length == 0) { throw new IllegalArgumentException("Invalid search specification string"); } String searchName = searchSpec[0]; searchSpec[0] = ""; setSearch(ASSearch.forName(searchName, searchSpec)); }