本文整理汇总了Java中weka.attributeSelection.AttributeSelection.setEvaluator方法的典型用法代码示例。如果您正苦于以下问题:Java AttributeSelection.setEvaluator方法的具体用法?Java AttributeSelection.setEvaluator怎么用?Java AttributeSelection.setEvaluator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类weka.attributeSelection.AttributeSelection
的用法示例。
在下文中一共展示了AttributeSelection.setEvaluator方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: preProcessData
import weka.attributeSelection.AttributeSelection; //导入方法依赖的package包/类
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;
}
开发者ID:PacktPublishing,项目名称:Machine-Learning-End-to-Endguide-for-Java-developers,代码行数:52,代码来源:KddCup.java
示例2: featureSelection
import weka.attributeSelection.AttributeSelection; //导入方法依赖的package包/类
/**
* Method featureSelection, which uses an algorithm to select the most representative features of
* the data in patterns_krs table
*
* @param data The instances from patterns_krs table
*
* @return indexes The indexes of the attributes selected by the algorithm
*/
public int[] featureSelection(Instances data){
int[] indexes = null;
AttributeSelection attsel = new AttributeSelection();
//FuzzyRoughSubsetEval eval = new FuzzyRoughSubsetEval();
//HillClimber search = new HillClimber();
CfsSubsetEval eval = new CfsSubsetEval();
GreedyStepwise search = new GreedyStepwise();
attsel.setEvaluator(eval);
attsel.setSearch(search);
try {
attsel.SelectAttributes(data);
indexes = attsel.selectedAttributes();
logger.info("Selected Features: "+Utils.arrayToString(indexes));
} catch (Exception e) {
e.printStackTrace();
}
return indexes;
}
示例3: selectFeatures
import weka.attributeSelection.AttributeSelection; //导入方法依赖的package包/类
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) {
}
}
示例4: getAttributeSelector
import weka.attributeSelection.AttributeSelection; //导入方法依赖的package包/类
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;
}