当前位置: 首页>>代码示例>>Java>>正文


Java AttributeSelection.setSearch方法代码示例

本文整理汇总了Java中weka.attributeSelection.AttributeSelection.setSearch方法的典型用法代码示例。如果您正苦于以下问题:Java AttributeSelection.setSearch方法的具体用法?Java AttributeSelection.setSearch怎么用?Java AttributeSelection.setSearch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在weka.attributeSelection.AttributeSelection的用法示例。


在下文中一共展示了AttributeSelection.setSearch方法的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;
   
}
 
开发者ID:MusesProject,项目名称:MusesServer,代码行数:31,代码来源:DataMiner.java

示例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) {
	}
}
 
开发者ID:PacktPublishing,项目名称:Java-Data-Science-Cookbook,代码行数:14,代码来源:WekaFeatureSelectionTest.java

示例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;
}
 
开发者ID:qcri-social,项目名称:AIDR,代码行数:12,代码来源:ModelFactory.java


注:本文中的weka.attributeSelection.AttributeSelection.setSearch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。