The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here

Creating attributes

PatrickPatrick Member Posts: 3 Contributor I
edited November 2018 in Help
I am trying to create an attribute with existing variables containing hyphens.

ex: a-1

However, when I try to use the AttributeConstructor in conjunction with this variable name, it misinterprets this as the variable a (nonexistent) subtracted by 1.

I have worked around this by using the Attribute renaming facility, however this is proving cumbersome as 120 of my 154 variables contain hyphens.

Is there an easier way to encapsulate a variable name containing ambiguous characters such as the hyphen?

Thanks,

- Pat

Answers

  • IngoRMIngoRM Employee-RapidMiner, RapidMiner Certified Analyst, RapidMiner Certified Expert, Community Manager, RMResearcher, Member, University Professor Posts: 1,751 RM Founder
    Hello Pat,

    in RM 4.4 there is a new operator called "ChangeAttributeNamesReplace" which can be used to replace all non-word characters (regular expression for replace_what is '\W') by an empty string or for example an underscore (replace_by could be "_"). If you apply this operator to all attributes (regular expression for the attribute names parameter would be ".*") then you end up with attribute names which can be used by the AttributeConstruction operator.

    Hope that helps,
    Ingo
  • haddockhaddock Member Posts: 849 Maven
    Just like this...
    <operator name="Root" class="Process" expanded="yes">
        <operator name="ExampleSetGenerator" class="ExampleSetGenerator">
            <parameter key="number_examples" value="200"/>
            <parameter key="number_of_attributes" value="2"/>
            <parameter key="target_function" value="random"/>
        </operator>
        <operator name="ChangeAttributeName" class="ChangeAttributeName">
            <parameter key="new_name" value="X-1"/>
            <parameter key="old_name" value="att1"/>
        </operator>
        <operator name="ChangeAttributeNamesReplace" class="ChangeAttributeNamesReplace">
            <parameter key="apply_on_special" value="false"/>
            <parameter key="attributes" value="X.*"/>
            <parameter key="replace_by" value="_"/>
            <parameter key="replace_what" value="\-"/>
        </operator>
    </operator>
Sign In or Register to comment.