public static void main(String[] args) throws Exception {
File file = StreamHandler.writeToFile(StreamHelper.resolve("sequences"));
Dataset data = FileHandler.loadDataset(file, 4, ",");
// ensemble feature selection
RecursiveFeatureEliminationSVM[] svmrfes = new RecursiveFeatureEliminationSVM[10];
for (int i = 0; i < svmrfes.length; i++)
svmrfes[i] = new RecursiveFeatureEliminationSVM(0.2);
LinearRankingEnsemble ensemble = new LinearRankingEnsemble(svmrfes);
ensemble.build(data);
for (int i = 0; i < ensemble.noAttributes(); i++)
System.out.println(ensemble.rank(i));
// feature scoring
GainRatio ga = new GainRatio();
ga.build(data);
for (int i = 0; i < ga.noAttributes(); i++)
System.out.println(ga.score(i));
// feature ranking
RecursiveFeatureEliminationSVM svmrfe = new RecursiveFeatureEliminationSVM(0.2);
svmrfe.build(data);
for (int i = 0; i < svmrfe.noAttributes(); i++)
System.out.println(svmrfe.rank(i));
}
}
No comments:
Post a Comment