"recreate exampleset after feature selection in javacode"

mw
mw New Altair Community Member
edited November 5 in Community Q&A
Hi all,

I can't find out how to rebuild or reduce my exampleset after feature selection in javacode, I've been trying for days. In Weka's AttributeSelection you can do that by using reduceDimensionality. My features are numeric and my classlabel is nominal. Before feature selection I have about 500 examples in my exampleset each represented by over a thousand attributes. Attribute selection reduces those thousand attributes to, say, 20 attributes. How can I represent the 500 examples in my exampleset represent with the 20 attributes in javacode?

Any suggestion will be much appreciated,

Martine

Answers

  • land
    land New Altair Community Member
    Hi Martine,
    if you want to remove an attribute from a given example set, simply use this code:
    Attributes attributes = exampleSet.getAttributes();
    Iterator<Attribute> iterator = attributes.iterator();
    while(iterator.hasNext()) {
      Attribute attribute = iterator.next();
      if (matchesSomeCondition(attribute)) {
        iterator.remove();
      }
    }
    Greetings,
      Sebastian
  • land
    land New Altair Community Member
    Hi,
    since I noticed your other post that you are still using RapidMiner 4.2, I must append, that I'm not sure if it works this way in this ancient version.

    Greetings,
      Sebastian