🎉 🎉 RAPIDMINER 9.10 IS OUT!!! 🎉🎉

Download the latest version helping analytics teams accelerate time-to-value for streaming and IIOT use cases.

CLICK HERE TO DOWNLOAD

AttributeConstruction

laurablaurab Member Posts: 23  Maven
edited November 2018 in Help
Hi,

I want to use the AttributConstruction operator so that a predictedd value can be used as the last attribute in the next atribute set. Where the first attribute is replaced by the secon attribute value, and so until the last attribute is replaced by the prediction value, a sliding window appraoch.  I.e so I can make twelve predictions.

I am farily sure that I am using the opertor incorrectly!  My attributes are called test.txt(1) to ... test.txt(12) so I tried the following

        <operator name="AttributeConstruction" class="AttributeConstruction">
            <list key="function_descriptions">
              <parameter key="test.txt(1)" value="  test.txt (2)"/>
              <parameter key="test.txt(2)" value=" test.txt (3)"/>
              .......
            <parameter key="test.txt(12)" value=" prediction"/>
            </list>
            <parameter key="keep_all" value="false"/>
        </operator>

I also tried with
      "  value=  "= test.txt (2)"/> "

I think the problem is with the refence made in "function expression" as it "does not know what test.txt" is.  How should I be  expressing the "function expression"? How should I be referenceing the name of the attribute ? ...It tells me that the attributes names are test.txt(1) to... test.txt(12) so why does it not recognise thet attribute when refenced as this?

Thanks

Laura


Answers

  • TobiasMalbrechtTobiasMalbrecht Moderator, Employee, Member Posts: 291  RM Product Management
    Hi Laura,

    unfortunately I did not quite understand what you want to accomplish. But one thing I can already say is that the [tt]AttributeConstruction[/tt] operator does not allow parantheses in the value fields, since it is assuming a function then. Hence, you have to rename your attributes beforehand.

    Regards,
    Tobias
  • laurablaurab Member Posts: 23  Maven
    Hi Tobias,

    Thanks for your reply.  I m a bit confused about the parenthesis thing as II did not put them in the XML it seems to do that automatically and is used on all the other operators on the "value".  And If I try :

            <operator name="AttributeConstruction" class="AttributeConstruction">
                <list key="function_descriptions">
                  <parameter key="test.txt(1)" value=test.txt (2)/>
                  <parameter key="test.txt(2)" value= test.txt (3)/>
                  <parameter key="test.txt(12)" value=prediction/>
                </list>
            </operator>

    ...i.e with no parenthesis around the value then it is not a happy bunny and I still the follwoing error:

    Error in: AttributeConstruction (AttributeConstruction) Generation exception: 'Unrecognized symbol "test.txt"
    Syntax Error (implicit multiplication not enabled)
    ' An operator failed to generate a new attribute

    I realise that I dont exaplin things very well so I will have another go. 

    intially I am using an examplesource operator to load in data from a text file in order to create the attribute file.  After the first prediction has been made (by an existing model)  i want to change the attributes set so that the first attrbiute is removed (this is already working) and that second attribute becomes the first attribute...  I just want to recyle my attributes set including the prediction results as a new attribute (dropping the first attribute).

    If I use the changeAttributeName operator it looks like I have to use one ChangeAttributeNames operator per attribute,

        <operator name="ChangeAttributeName" class="ChangeAttributeName" breakpoints="after">
            <parameter key="new_name" value="attribute (1)"/>
            <parameter key="old_name" value="test.txt (1)"/>
        </operator>

        <operator name="ChangeAttributeName (2)" class="ChangeAttributeName">
            <parameter key="new_name" value="attribute (2)"/>
            <parameter key="old_name" value="test.txt (2)"/>
        </operator

    is this correct or cann I change the name of all the attributes in one go? 

    I have tried this but with just the first two attributes.  Where I have renamed them using ChangeAttributeNames  from test.txt (x) to attribute (x). However when I try to use the attributeConstruction operator I get this :

    Error in: AttributeConstruction (AttributeConstruction) Generation exception: 'Unrecognized symbol "attribute"
    Syntax Error (implicit multiplication not enabled)
    ' An operator failed to generate a new attribute.

    This is the XML for the attributeConstruction :

      <operator name="AttributeConstruction" class="AttributeConstruction" breakpoints="after">
                <list key="function_descriptions">
                  <parameter key="attribute (1)" value="attribute (2)"/>
                </list>
            </operator>

    I Hope this is clearer

    Many thanks

    Laura
  • TobiasMalbrechtTobiasMalbrecht Moderator, Employee, Member Posts: 291  RM Product Management
    laurab wrote:

    If I use the changeAttributeName operator it looks like I have to use one ChangeAttributeNames operator per attribute,

        <operator name="ChangeAttributeName" class="ChangeAttributeName" breakpoints="after">
            <parameter key="new_name" value="attribute (1)"/>
            <parameter key="old_name" value="test.txt (1)"/>
        </operator>

        <operator name="ChangeAttributeName (2)" class="ChangeAttributeName">
            <parameter key="new_name" value="attribute (2)"/>
            <parameter key="old_name" value="test.txt (2)"/>
        </operator

    is this correct or cann I change the name of all the attributes in one go? 

    I have tried this but with just the first two attributes.  Where I have renamed them using ChangeAttributeNames  from test.txt (x) to attribute (x). However when I try to use the attributeConstruction operator I get this :

    Error in: AttributeConstruction (AttributeConstruction) Generation exception: 'Unrecognized symbol "attribute"
    Syntax Error (implicit multiplication not enabled)
    ' An operator failed to generate a new attribute.

    This is the XML for the attributeConstruction :

      <operator name="AttributeConstruction" class="AttributeConstruction" breakpoints="after">
                <list key="function_descriptions">
                  <parameter key="attribute (1)" value="attribute (2)"/>
                </list>
            </operator>

    I Hope this is clearer
    Well, not really. Once again: do not use parenthesis in the attribute names if you plan to process them by the [tt]AttributeConstruction[/tt] operator. Use something like that

    <operator name="ChangeAttributeName" class="ChangeAttributeName" breakpoints="after">
        <parameter key="new_name" value="attribute1"/>
        <parameter key="old_name" value="test.txt (1)"/>
    </operator>
    <operator name="ChangeAttributeName (2)" class="ChangeAttributeName">
        <parameter key="new_name" value="attribute2"/>
        <parameter key="old_name" value="test.txt (2)"/>
    </operator>
    Then you should be able to use the attributes att1 and att2 in the [tt]AttributeConstruction[/tt]. Alternatively to using the change name operators, you can put a line at the beginning of your text file specifying the attribute names, such as:

    att1;att2;att3;......
    It depends of course on the delimeters you have chosen etc. how this line should look. However, you spare changing all the attribute names by adding such a line.

    Two things: I still do not quite get what you are intending to do with the attribute constructions. But it seems a little bit strange to me, mapping one attribute onto another one (which also yet existis)! Secondly, are you aware that there are special purpose operators for sliding window processings?

    Regards,
    Tobias
  • laurablaurab Member Posts: 23  Maven
    Hi Tobias,

    Thanks for getting back to me. I was not aware of a sliding window operator and would very much like to use it.  What is it called? as i have had a look buit still can not see one.

    I realise that it is not very effiecnt to recreate all the attributes each time for the sake of added one new attribute but I thought that was the only way of achieving what I wanted to do. 

    Thanks
    Laura
  • laurablaurab Member Posts: 23  Maven
    Hi Tobias,

    I have found the slidding window tool in validation,

    Thanks Laura
  • TobiasMalbrechtTobiasMalbrecht Moderator, Employee, Member Posts: 291  RM Product Management
    Hi Laura,

    in the validation group there is only a sliding window validation operator. You should probably use the [tt]MultivariateSeries2WindowExamples[/tt] operator although I still do not have an idea of how your data looks like and in which format it is given ... But the aforementioned operator is the operator which converts simple time series to window examples.

    Regards,
    Tobias
  • laurablaurab Member Posts: 23  Maven
    Hi Tobias, 

    Yeah I realied that the other sliding window tools was only for validation and as such was not using it.

    I will look into the MultivariateSeries2WindowExamples.

    Thanks

    Laura
  • laurablaurab Member Posts: 23  Maven
    Hi Tobias,

    I have had a look at the MultivariateSeries2WindowExamples however it does not seem to do what i am after. 

    The MultivariateSeries2WindowExamples flattens out all my data examples in my dataset into one row. This is not
    what I want to do. 

    What I would like to do is: 

    I give my model (which is already trained) a dataset with sales volume for months
       
                    Jan,  Feb,  Mar, apr,  may and I want it to predict June. 
                    att1, att2, att3, att4, att5

    Then I would like (without alot of dataprocessing / remapping) to make a prediction using 
         
                  Feb, Mar, apr, may, june (prediction just made)  and I want it to predict July.

    Where june is the prediction that has just been formed. In this way I want to make predictions for a year. 

    I have successfully set up an process in rapidminer that will do this although I 'm sure that the way I have done
    is not the optimum way. I am achieving this in the way we discvussed in one of the previous post on this thread:

    <operator name="IteratingOperatorChain" class="IteratingOperatorChain" expanded="yes">
            <parameter key="iterations" value="6"/>
            <operator name="ModelLoader" class="ModelLoader" breakpoints="after">
                <parameter key="model_file" value="G:\Forecasting\Model\EF_TX_MKPARK_Geo_-All_NC_6M_Bin.mod"/>
            </operator>
            <operator name="ModelApplier" class="ModelApplier" breakpoints="after">
                <list key="application_parameters">
                </list>
            </operator>
            <operator name="ChangeAttributeRole" class="ChangeAttributeRole" breakpoints="after">
                <parameter key="name" value="prediction"/>
            </operator>
            <operator name="FeatureRangeRemoval" class="FeatureRangeRemoval" breakpoints="after">
                <parameter key="first_attribute" value="1"/>
                <parameter key="last_attribute" value="1"/>
            </operator>
            <operator name="OperatorChain" class="OperatorChain" breakpoints="after" expanded="yes">
                <operator name="ChangeAttributeName" class="ChangeAttributeName">
                    <parameter key="new_name" value="att1"/>
                    <parameter key="old_name" value="att2"/>
                </operator>
                <operator name="ChangeAttributeName (2)" class="ChangeAttributeName">
                    <parameter key="new_name" value="att2"/>
                    <parameter key="old_name" value="att3"/>
                </operator>
    .....
    .....
    .....
            <operator name="ChangeAttributeName (12)" class="ChangeAttributeName">
                    <parameter key="new_name" value="att12"/>
                    <parameter key="old_name" value="prediction(EF_TR_MKRESP_Geo_-All_NC_12M.txt (13))"/>
            </operator>

    And this works fine in rapidminer!!

    but  it wont work in Java.  If I set up the process in Java to be exactly like the above xml then an error is caused ("Cant find 'PRediction..' "). 

    However If I change the order of operators in Java so that The "ChangeAttributeRole" operator is last in the process then will work to some degree.

    If you look at the output from the process, and look at SimpleExampleSet:

    ExampleTable, 14 attributes, 2 data rows,
    attributes: [#0: att1 (real/single_value), #1: att2 (real/single_value),..... #10: att11 (real/single_value), #11:

    att12 (real/single_value), #12: att12 (real/single_value), #13: att12 (real/single_value)]

    it has ended up with three attributes called "att12" when there should only be one!

    SimpleExampleSet:
    2 examples,
    12 regular attributes,
    no special attributes

    Where as the RemmapedExampleSet:

    RemappedExampleSet:
    2 examples,
    10 regular attributes,
    special attributes = {
        prediction = #13: att12 (real/single_value)
    }

    But I should have 12 regular attributes. The datavalues returned by the remappedExampleset include ?

    hello results : 409.182 366.367 369.274 370.985 348.359 299.909 329.554 341.219 374.352  ?  394.265
    original attribute name: att3,  att4,  att5    att6    att7    att8    att9    att10  att11      att12

    Sorry that the post is so long, really hope you can help !!

    Many Thanks, Laura
  • laurablaurab Member Posts: 23  Maven
    sorry this bit looked wrong on the last post. Should look like this:


    hello results :      409.182  366.367  369.274  370.985  348.359  299.909  329.554  341.219  374.352  ?    394.265
    original att name: att3,          att4,        att5          att6        att7        att8          att9          att10          att11            att12
  • laurablaurab Member Posts: 23  Maven
    Hi, 

    Just wanted to let you know that I have fixed my problem wthout much data processing

    Thanks, sorry I have wasted your time on this problem!

    Laura
Sign In or Register to comment.