List of usage examples for weka.attributeSelection AttributeSelection setRanking
public void setRanking(boolean r)
From source file:mlflex.WekaInMemoryLearner.java
License:Open Source License
@Override protected ArrayList<String> SelectOrRankFeatures(ArrayList<String> algorithmParameters, DataInstanceCollection trainData, DataInstanceCollection dependentVariableInstances) throws Exception { ArrayList<String> dataPointNames = Lists.SortStringList(trainData.GetDataPointNames()); FastVector attVector = GetAttributeVector(dependentVariableInstances, dataPointNames, trainData); Instances instances = GetInstances(dependentVariableInstances, attVector, trainData); AttributeSelection attsel = new AttributeSelection(); ASEvaluation eval = GetAttributeEvaluator(algorithmParameters); ASSearch search = GetSearchMethod(algorithmParameters); attsel.setEvaluator(eval);// www .j a va 2 s . c om attsel.setSearch(search); boolean isRanker = algorithmParameters.get(2).equals(Ranker.class.getName()); if (isRanker) attsel.setRanking(true); attsel.SelectAttributes(instances); ArrayList<String> features = new ArrayList<String>(); if (isRanker) { for (double[] rank : attsel.rankedAttributes()) features.add(instances.attribute((int) rank[0]).name()); } else { for (int i : attsel.selectedAttributes()) features.add(instances.attribute(i).name()); } instances = null; return features; }