"Rename Premises and Conclusion of Association Rules"

stfnstfn Member Posts: 20 Maven
edited June 2019 in Help

Hello,

 

I was wondrering if there was a way to Rename the results of Association Rules. Here is my code

<?xml version="1.0" encoding="UTF-8"?><process version="7.4.000">
<context>
<input/>
<output/>
<macros/>
</context>
<operator activated="true" class="process" compatibility="7.4.000" expanded="true" name="Process">
<process expanded="true">
<operator activated="true" class="retrieve" compatibility="7.4.000" expanded="true" height="68" name="Retrieve" width="90" x="45" y="136">
<parameter key="repository_entry" value="../data/testData"/>
</operator>
<operator activated="false" class="read_excel" compatibility="7.4.000" expanded="true" height="68" name="Read Excel" width="90" x="45" y="34">
<parameter key="excel_file" value="C:\Users\Stefi\Desktop\Diplomatiki\results\re.xlsx"/>
<parameter key="imported_cell_range" value="A1:BM705"/>
<list key="annotations"/>
<list key="data_set_meta_data_information"/>
</operator>
<operator activated="true" class="numerical_to_binominal" compatibility="7.4.000" expanded="true" height="82" name="Numerical to Binominal" width="90" x="179" y="136">
<parameter key="include_special_attributes" value="true"/>
</operator>
<operator activated="true" class="fp_growth" compatibility="7.4.000" expanded="true" height="82" name="FP-Growth" width="90" x="313" y="136">
<parameter key="find_min_number_of_itemsets" value="false"/>
<parameter key="min_support" value="0.001"/>
</operator>
<operator activated="true" class="create_association_rules" compatibility="7.4.000" expanded="true" height="82" name="Create Association Rules" width="90" x="447" y="136"/>
<operator activated="true" class="store" compatibility="7.4.000" expanded="true" height="68" name="Store" width="90" x="581" y="136">
<parameter key="repository_entry" value="../data/AssociationRules"/>
</operator>
<connect from_op="Retrieve" from_port="output" to_op="Numerical to Binominal" to_port="example set input"/>
<connect from_op="Numerical to Binominal" from_port="example set output" to_op="FP-Growth" to_port="example set"/>
<connect from_op="FP-Growth" from_port="frequent sets" to_op="Create Association Rules" to_port="item sets"/>
<connect from_op="Create Association Rules" from_port="rules" to_op="Store" to_port="input"/>
<connect from_op="Store" from_port="through" to_port="result 1"/>
<portSpacing port="source_input 1" spacing="0"/>
<portSpacing port="sink_result 1" spacing="0"/>
<portSpacing port="sink_result 2" spacing="0"/>
</process>
</operator>
</process>

 

And these are my results among othersCapture.JPG

My question is that i want to translate these IDs (eg '321-1106') to 'Data Bases' (for example).

Is there any way to do this?

 

Thanks in advance,

stfn

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Best Answer

  • Telcontar120Telcontar120 Moderator, RapidMiner Certified Analyst, RapidMiner Certified Expert, Member Posts: 1,635 Unicorn
    Solution Accepted

    Yes, but you need to download the Converter extension from the Marketplace to do it (it's free).  In that extension there is an operator to change the association rules to an ordinary exampleset.  Then you can rename the attributes using Rename (or one of the other variants) and do whatever other data ETL you might want.

     

     

     

    Brian T.
    Lindon Ventures 
    Data Science Consulting from Certified RapidMiner Experts

Answers

  • Thomas_OttThomas_Ott RapidMiner Certified Analyst, RapidMiner Certified Expert, Member Posts: 1,761 Unicorn

    You have to frist use the Convertors extension where you can export the Association Rules as an example set. Then you could use the Rename operator. That allows you to rename the attribute column names. 

  • stfnstfn Member Posts: 20 Maven

    thank you very much for your reply

  • stfnstfn Member Posts: 20 Maven

    Thank you! That worked well for me!

     

     

    Capture.JPGCan i ask you something else. When i use "RENAME", if there is no such attribute name (eg.  32110200) i have an error. Can i skip this? I mean if there is not the specific attribute name to skip this and continue to the next one. until it finds those which exist and replace?

  • BalazsBaranyBalazsBarany Administrator, Moderator, Employee, RapidMiner Certified Analyst, RapidMiner Certified Expert Posts: 955 Unicorn

    Hi,

     

    there are at least two ways to solve this.

     

    1. Put the Rename operator into an Exception handler. If the attribute is there, the Rename will be executed. If not, you just return the original example set (connect the ports in the right part of the nested operator).

     

    2. You can also select the renamed attribute with a regular expression instead of "single". If it matches, fine; if not, nothing will happen.

     

    Regards,

    Balázs

  • BalazsBaranyBalazsBarany Administrator, Moderator, Employee, RapidMiner Certified Analyst, RapidMiner Certified Expert Posts: 955 Unicorn

    (Solution 2 would work with the Rename by Replacing operator.)

  • stfnstfn Member Posts: 20 Maven

    Thank you for your reply.

     

    Could you please give me an example for using Handle Exception? 

     

    i have tried this but still if for example id "321-2201" is not in the results i have error. 

     

    Here is my code

    <?xml version="1.0" encoding="UTF-8"?><process version="7.4.000">
    <context>
    <input/>
    <output/>
    <macros/>
    </context>
    <operator activated="true" class="process" compatibility="7.4.000" expanded="true" name="Process">
    <parameter key="logverbosity" value="all"/>
    <process expanded="true">
    <operator activated="true" class="retrieve" compatibility="7.4.000" expanded="true" height="68" name="Retrieve" width="90" x="45" y="136">
    <parameter key="repository_entry" value="../data/AssociationRules"/>
    </operator>
    <operator activated="true" class="converters:rules_2_example_set" compatibility="0.3.000" expanded="true" height="82" name="Association Rules to ExampleSet" width="90" x="179" y="136"/>
    <operator activated="true" class="handle_exception" compatibility="7.4.000" expanded="true" height="82" name="Handle Exception" width="90" x="313" y="136">
    <process expanded="true">
    <operator activated="true" class="loop_attributes" compatibility="7.4.000" expanded="true" height="82" name="Loop Attributes" width="90" x="112" y="136">
    <process expanded="true">
    <operator activated="true" class="rename" compatibility="7.4.000" expanded="true" height="82" name="Rename (2)" width="90" x="179" y="34">
    <parameter key="old_name" value=" %{loop_attribute}"/>
    <parameter key="new_name" value="%{name}"/>
    <list key="rename_additional_attributes">
    <parameter key="321-2201" value="stef"/>
    </list>
    </operator>
    <connect from_port="example set" to_op="Rename (2)" to_port="example set input"/>
    <connect from_op="Rename (2)" from_port="example set output" to_port="example set"/>
    <portSpacing port="source_example set" spacing="0"/>
    <portSpacing port="sink_example set" spacing="0"/>
    <portSpacing port="sink_result 1" spacing="0"/>
    </process>
    </operator>
    <operator activated="false" class="rename_by_constructions" compatibility="7.4.000" expanded="true" height="82" name="Rename by Constructions" width="90" x="179" y="238"/>
    <connect from_port="in 1" to_op="Loop Attributes" to_port="example set"/>
    <connect from_op="Loop Attributes" from_port="example set" to_port="out 1"/>
    <portSpacing port="source_in 1" spacing="0"/>
    <portSpacing port="source_in 2" spacing="0"/>
    <portSpacing port="sink_out 1" spacing="0"/>
    <portSpacing port="sink_out 2" spacing="0"/>
    </process>
    <process expanded="true">
    <portSpacing port="source_in 1" spacing="0"/>
    <portSpacing port="source_in 2" spacing="0"/>
    <portSpacing port="sink_out 1" spacing="0"/>
    <portSpacing port="sink_out 2" spacing="0"/>
    </process>
    </operator>
    <operator activated="false" class="rename_by_replacing" compatibility="7.4.000" expanded="true" height="82" name="Rename by Replacing" width="90" x="112" y="340">
    <parameter key="attribute_filter_type" value="single"/>
    </operator>
    <operator activated="false" class="select_attributes" compatibility="7.4.000" expanded="true" height="82" name="Select Attributes" width="90" x="246" y="340">
    <parameter key="attribute_filter_type" value="single"/>
    <parameter key="attribute" value="Premises"/>
    </operator>
    <operator activated="false" class="rename_by_example_values" compatibility="7.4.000" expanded="true" height="82" name="Rename by Example Values" width="90" x="380" y="340"/>
    <connect from_op="Retrieve" from_port="output" to_op="Association Rules to ExampleSet" to_port="rules input"/>
    <connect from_op="Association Rules to ExampleSet" from_port="example set" to_op="Handle Exception" to_port="in 1"/>
    <connect from_op="Handle Exception" from_port="out 1" to_port="result 1"/>
    <portSpacing port="source_input 1" spacing="0"/>
    <portSpacing port="sink_result 1" spacing="0"/>
    <portSpacing port="sink_result 2" spacing="0"/>
    </process>
    </operator>
    </process>
  • BalazsBaranyBalazsBarany Administrator, Moderator, Employee, RapidMiner Certified Analyst, RapidMiner Certified Expert Posts: 955 Unicorn

    Hi,

     

    you didn't connect the input to the output of the Catch case. If an error happens, no output will be generated - not even the original one.

     

    Regards,

     

    Balázs

  • stfnstfn Member Posts: 20 Maven

    Thank you for the reply.

    I made a change and i am trying to make everything in one process.

     

    here is my new code

    <?xml version="1.0" encoding="UTF-8"?><process version="7.4.000">
    <context>
    <input/>
    <output/>
    <macros/>
    </context>
    <operator activated="true" class="process" compatibility="7.4.000" expanded="true" name="Process">
    <process expanded="true">
    <operator activated="true" class="jdbc_connectors:read_database" compatibility="7.4.000" expanded="true" height="68" name="Read Database" width="90" x="45" y="34">
    <parameter key="connection" value="New connection1"/>
    <parameter key="query" value="SELECT `lesson_id` AS Item, `status` AS Amount, `student_id` AS Id&#10;FROM `grades`&#10;WHERE `edate` BETWEEN '1999-01-15' AND '1999-02-28'"/>
    <enumeration key="parameters"/>
    </operator>
    <operator activated="true" class="replace" compatibility="7.4.000" expanded="true" height="82" name="Replace (1)" width="90" x="45" y="136">
    <parameter key="attribute_filter_type" value="single"/>
    <parameter key="attribute" value="Amount"/>
    <parameter key="replace_what" value="Success"/>
    <parameter key="replace_by" value="1"/>
    </operator>
    <operator activated="true" class="replace" compatibility="7.4.000" expanded="true" height="82" name="Replace (3)" width="90" x="45" y="238">
    <parameter key="attribute_filter_type" value="single"/>
    <parameter key="attribute" value="Amount"/>
    <parameter key="replace_what" value="Fail"/>
    <parameter key="replace_by" value="0"/>
    </operator>
    <operator activated="true" class="parse_numbers" compatibility="7.4.000" expanded="true" height="82" name="Parse Numbers (3)" width="90" x="45" y="340">
    <parameter key="attribute_filter_type" value="single"/>
    <parameter key="attribute" value="Amount"/>
    <parameter key="grouped_digits" value="true"/>
    <parameter key="unparsable_value_handling" value="replace with missing values"/>
    </operator>
    <operator activated="true" class="aggregate" compatibility="7.4.000" expanded="true" height="82" name="Aggregate (2)" width="90" x="179" y="34">
    <parameter key="use_default_aggregation" value="true"/>
    <parameter key="attribute_filter_type" value="single"/>
    <parameter key="attribute" value="Status"/>
    <parameter key="default_aggregation_function" value="sum"/>
    <list key="aggregation_attributes">
    <parameter key="Amount" value="sum"/>
    </list>
    <parameter key="group_by_attributes" value="Id|Item"/>
    </operator>
    <operator activated="true" class="pivot" compatibility="7.4.000" expanded="true" height="82" name="Pivot (2)" width="90" x="179" y="136">
    <parameter key="group_attribute" value="Id"/>
    <parameter key="index_attribute" value="Item"/>
    </operator>
    <operator activated="true" class="rename_by_replacing" compatibility="7.4.000" expanded="true" height="82" name="Rename by Replacing" width="90" x="179" y="238">
    <parameter key="include_special_attributes" value="true"/>
    <parameter key="replace_what" value="sum[-!&quot;#$%&amp;'()*+,./:;&lt;=&gt;?@\[\\\]_`{|}~]Amount[-!&quot;#$%&amp;'()*+,./:;&lt;=&gt;?@\[\\\]_`{|}~]_"/&gt;
    <parameter key="replace_by" value=" "/>
    </operator>
    <operator activated="true" class="numerical_to_binominal" compatibility="7.4.000" expanded="true" height="82" name="Numerical to Binominal" width="90" x="179" y="340"/>
    <operator activated="true" class="set_role" compatibility="7.4.000" expanded="true" height="82" name="Set Role" width="90" x="313" y="34">
    <parameter key="attribute_name" value="Id"/>
    <parameter key="target_role" value="id"/>
    <list key="set_additional_roles"/>
    </operator>
    <operator activated="true" class="handle_exception" compatibility="7.4.000" expanded="true" height="82" name="Handle Exception" width="90" x="313" y="136">
    <parameter key="exception_macro" value="exp"/>
    <process expanded="true">
    <operator activated="true" class="concurrency:loop_attributes" compatibility="7.4.000" expanded="true" height="82" name="Loop Attributes" width="90" x="112" y="34">
    <parameter key="attributes" value="Id"/>
    <process expanded="true">
    <operator activated="true" class="rename" compatibility="7.4.000" expanded="true" height="82" name="Rename" width="90" x="313" y="34">
    <parameter key="old_name" value="Id"/>
    <parameter key="new_name" value="lesson id"/>
    <list key="rename_additional_attributes">
    <parameter key="321-1400" value="stefania"/>
    <parameter key="321-1200" value="stefania2"/>
    </list>
    </operator>
    <connect from_port="input 1" to_op="Rename" to_port="example set input"/>
    <connect from_op="Rename" from_port="example set output" to_port="output 1"/>
    <portSpacing port="source_input 1" spacing="0"/>
    <portSpacing port="source_input 2" spacing="0"/>
    <portSpacing port="sink_output 1" spacing="0"/>
    <portSpacing port="sink_output 2" spacing="0"/>
    </process>
    </operator>
    <connect from_port="in 1" to_op="Loop Attributes" to_port="input 1"/>
    <connect from_op="Loop Attributes" from_port="output 1" to_port="out 1"/>
    <portSpacing port="source_in 1" spacing="0"/>
    <portSpacing port="source_in 2" spacing="0"/>
    <portSpacing port="sink_out 1" spacing="0"/>
    <portSpacing port="sink_out 2" spacing="0"/>
    </process>
    <process expanded="true">
    <operator activated="false" class="print_to_console" compatibility="7.4.000" expanded="true" height="68" name="Print to Console" width="90" x="112" y="34">
    <parameter key="log_value" value="%{exp}"/>
    </operator>
    <connect from_port="in 1" to_port="out 1"/>
    <portSpacing port="source_in 1" spacing="0"/>
    <portSpacing port="source_in 2" spacing="0"/>
    <portSpacing port="sink_out 1" spacing="0"/>
    <portSpacing port="sink_out 2" spacing="0"/>
    </process>
    </operator>
    <operator activated="false" class="select" compatibility="7.4.000" expanded="true" height="68" name="Select" width="90" x="313" y="289"/>
    <operator activated="true" class="fp_growth" compatibility="7.4.000" expanded="true" height="82" name="FP-Growth" width="90" x="447" y="34">
    <parameter key="find_min_number_of_itemsets" value="false"/>
    <parameter key="positive_value" value="true"/>
    <parameter key="min_support" value="0.005"/>
    </operator>
    <operator activated="true" class="create_association_rules" compatibility="7.4.000" expanded="true" height="82" name="Create Association Rules" width="90" x="447" y="238"/>
    <operator activated="false" class="store" compatibility="7.4.000" expanded="true" height="68" name="Store" width="90" x="447" y="391">
    <parameter key="repository_entry" value="../data/test1Data"/>
    </operator>
    <operator activated="false" class="read_excel" compatibility="7.4.000" expanded="true" height="68" name="Read Excel" width="90" x="45" y="442">
    <list key="annotations"/>
    <list key="data_set_meta_data_information"/>
    </operator>
    <connect from_op="Read Database" from_port="output" to_op="Replace (1)" to_port="example set input"/>
    <connect from_op="Replace (1)" from_port="example set output" to_op="Replace (3)" to_port="example set input"/>
    <connect from_op="Replace (3)" from_port="example set output" to_op="Parse Numbers (3)" to_port="example set input"/>
    <connect from_op="Parse Numbers (3)" from_port="example set output" to_op="Aggregate (2)" to_port="example set input"/>
    <connect from_op="Aggregate (2)" from_port="example set output" to_op="Pivot (2)" to_port="example set input"/>
    <connect from_op="Pivot (2)" from_port="example set output" to_op="Rename by Replacing" to_port="example set input"/>
    <connect from_op="Rename by Replacing" from_port="example set output" to_op="Numerical to Binominal" to_port="example set input"/>
    <connect from_op="Numerical to Binominal" from_port="example set output" to_op="Set Role" to_port="example set input"/>
    <connect from_op="Set Role" from_port="example set output" to_op="Handle Exception" to_port="in 1"/>
    <connect from_op="Handle Exception" from_port="out 1" to_op="FP-Growth" to_port="example set"/>
    <connect from_op="FP-Growth" from_port="frequent sets" to_op="Create Association Rules" to_port="item sets"/>
    <connect from_op="Create Association Rules" from_port="rules" to_port="result 1"/>
    <portSpacing port="source_input 1" spacing="0"/>
    <portSpacing port="sink_result 1" spacing="0"/>
    <portSpacing port="sink_result 2" spacing="0"/>
    </process>
    </operator>
    </process>

    The thing is that i still have no "renames". 

    Any ideas?

     

    Thanks :)

     

     

     

Sign In or Register to comment.