IF YOU ❤️ RAPIDMINER, PLEASE HELP US GET TO #1 AGAIN - VOTE IN KDNUGGETS POLL 2019! 🙏 🙏 🙏

Why does the Split operator not keep the values?

SylvainMSylvainM Member Posts: 18 Contributor II
Hello everyone,

As usual, I have quite a simple task to do but I haven't found an easy answer to it yet.


Let's say I have that Example Set:

Sale     

Clients      

Product

A

x

CCD

B

x ; y 

CCD

C

CS

D

CCD

E

x ; z 

DU

F

x ; y ; z

CS

G

y ; z

DU



And I want to split it to get that new Example Set: 

Sale    

Clients  

Product

A

x

CCD

B

CCD

B

y

CCD

C

CS

D

CCD

E

x

DU

E

z

DU

F

x

CS

F

y

CS

F

z

CS

G

y

DU

G

z

DU


What I thought first was: "Hey! You can do that! Let's do a Transpose, then a Split, and a Transpose again!" But this is what I get:

Sale     

Clients    

Product

?

y

?

?

z

?

?

y

?

?

z

?

?

z

?

A

x

CCD

B

x

CCD

C

y

CS

D

y

CCD

E

x

DU

F

x

CS

G

y

DU


Why did the Split operator not keep the values associated to the split examples? And what can I do to keep them?

I'm sorry if my question is obvious: I'm still exploring RapidMiner :smile:

Thanks a lot and best to all,
Sylvain

Answers

  • SylvainMSylvainM Member Posts: 18 Contributor II
    Update

    Hello everyone,

    After an hour of thought, I now understand why I got that result: Split gives an empty value if there is nothing to split; it doesn't copy the example.

    It does not solve my problem, however, which is to copy the example when there's nothing to split... Any advice on that point?

    Thanks a lot for your help :smile:
    Sylvain
    dbabrauskaite
  • IngoRMIngoRM Administrator, Moderator, Employee, RapidMiner Certified Analyst, RapidMiner Certified Expert, Community Manager, RMResearcher, Member, University Professor Posts: 1,595  RM Founder
    Nice challenge :smiley: 
    The process below should do the trick.  I have used a combination of Split, De-Pivot, and Filter Examples.  The other two operators are simply used to make the result look nicer / exactly like your example above...
    Hope this helps,
    Ingo
    P.S.: If anybody finds a shorter solution pls let me know - I only spend 5 minutes on this but I somehow feel that there is something shorter out there...
    <?xml version="1.0" encoding="UTF-8"?><process version="9.3.000-BETA2">
      <context>
        <input/>
        <output/>
        <macros/>
      </context>
      <operator activated="true" class="process" compatibility="9.3.000-BETA2" expanded="true" name="Process">
        <parameter key="logverbosity" value="init"/>
        <parameter key="random_seed" value="2001"/>
        <parameter key="send_mail" value="never"/>
        <parameter key="notification_email" value=""/>
        <parameter key="process_duration_for_mail" value="30"/>
        <parameter key="encoding" value="UTF-8"/>
        <process expanded="true">
          <operator activated="true" class="utility:create_exampleset" compatibility="9.3.000-BETA2" expanded="true" height="68" name="Create ExampleSet" width="90" x="45" y="34">
            <parameter key="generator_type" value="comma separated text"/>
            <parameter key="number_of_examples" value="100"/>
            <parameter key="use_stepsize" value="false"/>
            <list key="function_descriptions"/>
            <parameter key="add_id_attribute" value="false"/>
            <list key="numeric_series_configuration"/>
            <list key="date_series_configuration"/>
            <list key="date_series_configuration (interval)"/>
            <parameter key="date_format" value="yyyy-MM-dd HH:mm:ss"/>
            <parameter key="time_zone" value="SYSTEM"/>
            <parameter key="input_csv_text" value="Sale,Clients,Product&#10;A,x,CCD&#10;B,x ; y,CCD&#10;C,y,CS&#10;D,y,CCD&#10;E,x ; z,DU&#10;F,x ; y ; z,CS&#10;G,y ; z,DU&#10;"/>
            <parameter key="column_separator" value=","/>
            <parameter key="parse_all_as_nominal" value="false"/>
            <parameter key="decimal_point_character" value="."/>
            <parameter key="trim_attribute_names" value="true"/>
          </operator>
          <operator activated="true" class="split" compatibility="9.3.000-BETA2" expanded="true" height="82" name="Split" width="90" x="179" y="34">
            <parameter key="attribute_filter_type" value="single"/>
            <parameter key="attribute" value="Clients"/>
            <parameter key="attributes" value=""/>
            <parameter key="use_except_expression" value="false"/>
            <parameter key="value_type" value="nominal"/>
            <parameter key="use_value_type_exception" value="false"/>
            <parameter key="except_value_type" value="file_path"/>
            <parameter key="block_type" value="single_value"/>
            <parameter key="use_block_type_exception" value="false"/>
            <parameter key="except_block_type" value="single_value"/>
            <parameter key="invert_selection" value="false"/>
            <parameter key="include_special_attributes" value="false"/>
            <parameter key="split_pattern" value=" ; "/>
            <parameter key="split_mode" value="unordered_split"/>
          </operator>
          <operator activated="true" class="de_pivot" compatibility="9.3.000-BETA2" expanded="true" height="82" name="De-Pivot" width="90" x="313" y="34">
            <list key="attribute_name">
              <parameter key="TO_REMOVE" value="Clients_.*"/>
            </list>
            <parameter key="index_attribute" value="Client"/>
            <parameter key="create_nominal_index" value="true"/>
            <parameter key="keep_missings" value="false"/>
          </operator>
          <operator activated="true" class="filter_examples" compatibility="9.3.000-BETA2" expanded="true" height="103" name="Filter Examples" width="90" x="447" y="34">
            <parameter key="parameter_expression" value=""/>
            <parameter key="condition_class" value="custom_filters"/>
            <parameter key="invert_filter" value="false"/>
            <list key="filters_list">
              <parameter key="filters_entry_key" value="TO_REMOVE.equals.true"/>
            </list>
            <parameter key="filters_logic_and" value="true"/>
            <parameter key="filters_check_metadata" value="true"/>
          </operator>
          <operator activated="true" class="replace" compatibility="9.3.000-BETA2" expanded="true" height="82" name="Replace" width="90" x="581" y="34">
            <parameter key="attribute_filter_type" value="single"/>
            <parameter key="attribute" value="Client"/>
            <parameter key="attributes" value=""/>
            <parameter key="use_except_expression" value="false"/>
            <parameter key="value_type" value="nominal"/>
            <parameter key="use_value_type_exception" value="false"/>
            <parameter key="except_value_type" value="file_path"/>
            <parameter key="block_type" value="single_value"/>
            <parameter key="use_block_type_exception" value="false"/>
            <parameter key="except_block_type" value="single_value"/>
            <parameter key="invert_selection" value="false"/>
            <parameter key="include_special_attributes" value="false"/>
            <parameter key="replace_what" value="Clients_(.*)"/>
            <parameter key="replace_by" value="$1"/>
          </operator>
          <operator activated="true" class="select_attributes" compatibility="9.3.000-BETA2" expanded="true" height="82" name="Select Attributes" width="90" x="715" y="34">
            <parameter key="attribute_filter_type" value="single"/>
            <parameter key="attribute" value="TO_REMOVE"/>
            <parameter key="attributes" value=""/>
            <parameter key="use_except_expression" value="false"/>
            <parameter key="value_type" value="attribute_value"/>
            <parameter key="use_value_type_exception" value="false"/>
            <parameter key="except_value_type" value="time"/>
            <parameter key="block_type" value="attribute_block"/>
            <parameter key="use_block_type_exception" value="false"/>
            <parameter key="except_block_type" value="value_matrix_row_start"/>
            <parameter key="invert_selection" value="true"/>
            <parameter key="include_special_attributes" value="false"/>
          </operator>
          <connect from_op="Create ExampleSet" from_port="output" to_op="Split" to_port="example set input"/>
          <connect from_op="Split" from_port="example set output" to_op="De-Pivot" to_port="example set input"/>
          <connect from_op="De-Pivot" from_port="example set output" to_op="Filter Examples" to_port="example set input"/>
          <connect from_op="Filter Examples" from_port="example set output" to_op="Replace" to_port="example set input"/>
          <connect from_op="Replace" from_port="example set output" to_op="Select Attributes" to_port="example set input"/>
          <connect from_op="Select Attributes" from_port="example set output" 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>
    sgenzerdbabrauskaite
  • SylvainMSylvainM Member Posts: 18 Contributor II
    Hello Ingo,

    Your solution works perfectly well! It is short and clear, as I like :wink:

    Thank you soooo much! I'm learning a lot with you help.

    Best,
    Sylvain
  • sgenzersgenzer 12Administrator, Moderator, Employee, RapidMiner Certified Analyst, Community Manager, Member, University Professor, PM Moderator Posts: 2,261  Community Manager
    @SylvainM pls mark as solution. Thank you! :smiley:
Sign In or Register to comment.