Pages: [1]
  Print  
Author Topic: How to change role for attributes specified by regex?  (Read 1634 times)
keith
Full Member
***
Posts: 160


« on: September 08, 2008, 08:29:34 PM »

I have a group of attributes I want to change to a custom "donotuse" role.  This is for data that should not be used in the model, isn't the ID column, but that I want to still keep associated with the predictions and results for other purposes.

What I've tried to do is specify a regular expression that identifies the attributes, and have a single ChangeAttributeRole nested inside.  The FeatureIterator seemed like the right choice:

Code:
        <operator name="FeatureIterator" class="FeatureIterator" expanded="yes">
            <parameter key="filter" value="(name|address|city|state|zip)"/>
            <operator name="ChangeAttributeRole" class="ChangeAttributeRole">
                <parameter key="name" value="%{loop_feature}"/>
                <parameter key="target_role" value="donotuse"/>
            </operator>
        </operator>

But that only changes the role for the duration of that loop iteration.  AttributeSubsetPreprocessing specifically says that role change are not preserved, so that's out.  What's the right way to do it?

Thanks,
Keith
Logged
steffen
Sr. Member
****
Posts: 376



« Reply #1 on: September 09, 2008, 08:00:26 AM »

Hello

Just a few remarks:
First: I tried to do this using the AttributeSubsetPreprocessing...which worked
Code:
<operator name="Root" class="Process" expanded="yes">
    <operator name="ExampleSource" class="ExampleSource">
        <parameter key="attributes" value="\golf.aml"/>
    </operator>
    <operator name="AttributeSubsetPreprocessing" class="AttributeSubsetPreprocessing" expanded="yes">
        <parameter key="attribute_name_regex" value="Outlook|Temperature"/>
        <parameter key="deliver_inner_results" value="true"/>
        <operator name="ChangeAttributeRole" class="ChangeAttributeRole">
            <parameter key="name" value="Outlook"/>
            <parameter key="target_role" value="donotuse"/>
        </operator>
        <operator name="ChangeAttributeRole (2)" class="ChangeAttributeRole">
            <parameter key="name" value="Temperature"/>
            <parameter key="target_role" value="donotuse2"/>
        </operator>
    </operator>
</operator>
I admit that AttributSubsetProcessing is useless here...
However, giving the both roles the same name, did not work (change "donotuse2" to "donotuse" in the setup above). I guess it is a rule that a role can occur just once in an ExampleSet. In this case we need a special-default role, indeed or a switchon-switchoff-operator Wink

Second: It is possible to build a workaround with ParameterIteration, ExampleSetJoin etc ( I love the modelling abilities of RM)... but in this case you are better of changing every attribute "manually"

greetings

Steffen
Logged

"I want to make computers do what I mean instead of what I say"
Read The Fantastic Manual
Ingo Mierswa
Administrator
Hero Member
*****
Posts: 1221



WWW
« Reply #2 on: September 23, 2008, 04:14:29 PM »

Hi,

we just have added a new parameter to the "FeatureIterator" operator named "work_on_input". If you set this parameter to false, the output of the last loop run will be used as input for the next loop and finally returned. Here is an example:

Code:
<operator name="Root" class="Process" expanded="yes">
    <operator name="ExampleSetGenerator" class="ExampleSetGenerator">
        <parameter key="target_function" value="sum"/>
    </operator>
    <operator name="FeatureIterator" class="FeatureIterator" expanded="yes">
        <parameter key="filter" value="att2|att3"/>
        <parameter key="work_on_input" value="false"/>
        <operator name="ChangeAttributeRole" class="ChangeAttributeRole">
            <parameter key="name" value="%{loop_feature}"/>
            <parameter key="target_role" value="donotuse_%{a}"/>
        </operator>
    </operator>
</operator>

Cheers,
Ingo
Logged

Did you try our new Marketplace? Upload or download new Extensions, add comments, and organize your operators. Have a look at  http://marketplace.rapid-i.com
keith
Full Member
***
Posts: 160


« Reply #3 on: September 23, 2008, 09:54:09 PM »

Great! Thanks Ingo.  Does that mean that the new parameter is available if I download and build the latest CVS version?
Logged
Ingo Mierswa
Administrator
Hero Member
*****
Posts: 1221



WWW
« Reply #4 on: September 24, 2008, 10:18:57 AM »

Hi,

yes, it is. Basic information about downloading and installing the CVS version can be found here:

http://rapid-i.com/content/view/25/48/


Please note, however, that we have introduced a new developer branch into CVS named "Zaniah". So you will no longer have to checkout the "HEAD" branch but the branch "Zaniah" in order to get the latest features. The HEAD branch is now our bugfix branch where only bugfixed but no new feature will be added.

Cheers,
Ingo

Logged

Did you try our new Marketplace? Upload or download new Extensions, add comments, and organize your operators. Have a look at  http://marketplace.rapid-i.com
Pages: [1]
  Print  
 
Jump to: