PDA

View Full Version : Feature Selection by own java code



fersiniel
05-12-2009, 11:09 AM
Hi,
I've a problem with my own java code for feature selection.
The following java code works correctly, i.e. gives a list of attribute
---------------------------------------------------
Instances instances = new Instances (new FileReader(aFile));
instances.setClassIndex(instances.numAttributes()-1);
AttributeSelection attsel = new AttributeSelection(); // package
weka.attributeSelection!
CfsSubsetEval eval = new CfsSubsetEval();
BestFirst search = new BestFirst();
attsel.setEvaluator(eval);
attsel.setSearch(search);
attsel.SelectAttributes(instances);
System.out.println(attsel.toResultsString());
// obtain the attribute indices that were selected
int[] indices = attsel.selectedAttributes();
---------------------------------------------------

but the output (feature list) is different from the one obtained (with the
same parameter) by the Explorer gui. More specifically the attribute list
obtained by my code is a subset contained into the one obtained through the
Explorer gui (all the attributes obtained by myself is present into the
attribute list given by the Explorer, but the Explorer list contains some
additional feature).

Do you have any idea about the motivation? Is there any mistake in my code?

Many Thanks,
Elisabetta

Mark
05-13-2009, 09:52 PM
For the benefit of others - this query was addressed on the Weka mailing list in this thread:

https://list.scms.waikato.ac.nz/mailman/htdig/wekalist/2009-May/017527.html

Cheers,
Mark.