weka.attributeSelection.InfoGainAttributeEval Java Examples
The following examples show how to use
weka.attributeSelection.InfoGainAttributeEval.
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: ModelFactory.java From AIDR with GNU Affero General Public License v3.0 | 6 votes |
private static AttributeSelection getAttributeSelector( Instances trainingData) throws Exception { AttributeSelection selector = new AttributeSelection(); InfoGainAttributeEval evaluator = new InfoGainAttributeEval(); Ranker ranker = new Ranker(); ranker.setNumToSelect(Math.min(500, trainingData.numAttributes() - 1)); selector.setEvaluator(evaluator); selector.setSearch(ranker); selector.SelectAttributes(trainingData); return selector; }
Example #2
Source File: KddCup.java From Machine-Learning-in-Java with MIT License | 4 votes |
public static Instances preProcessData(Instances data) throws Exception{ /* * Remove useless attributes */ RemoveUseless removeUseless = new RemoveUseless(); removeUseless.setOptions(new String[] { "-M", "99" }); // threshold removeUseless.setInputFormat(data); data = Filter.useFilter(data, removeUseless); /* * Remove useless attributes */ ReplaceMissingValues fixMissing = new ReplaceMissingValues(); fixMissing.setInputFormat(data); data = Filter.useFilter(data, fixMissing); /* * Remove useless attributes */ Discretize discretizeNumeric = new Discretize(); discretizeNumeric.setOptions(new String[] { "-O", "-M", "-1.0", "-B", "4", // no of bins "-R", "first-last"}); //range of attributes fixMissing.setInputFormat(data); data = Filter.useFilter(data, fixMissing); /* * Select only informative attributes */ InfoGainAttributeEval eval = new InfoGainAttributeEval(); Ranker search = new Ranker(); search.setOptions(new String[] { "-T", "0.001" }); // information gain threshold AttributeSelection attSelect = new AttributeSelection(); attSelect.setEvaluator(eval); attSelect.setSearch(search); // apply attribute selection attSelect.SelectAttributes(data); // remove the attributes not selected in the last run data = attSelect.reduceDimensionality(data); return data; }