How to set the filename of the loaded data as an attribute

oliver23oliver23 Member Posts: 4 Contributor I
edited November 2018 in Help

Hi

 this is probably a very simple thing to do in RapiMiner, but I can not find a way how to do it:

can someone please show me how to set the filename of the loaded data as an attribute ?

Much appreciated !

 

Oliver

 

Tagged:

Answers

  • mschmitzmschmitz Administrator, Moderator, Employee, RapidMiner Certified Analyst, RapidMiner Certified Expert, University Professor Posts: 1,952  RM Data Scientist

    Hi Oliver,

     

    if you read Files with Read Excel or Read CSV or even with a Read Database they have an annotation called source which includes the path. That means you do not forget the original location.

    You can add this annotation as a attribute to your table if you want to. Attached is a process demonstrating it.

     

    Best,

    Martin

     

    <?xml version="1.0" encoding="UTF-8"?><process version="8.0.001">
    <context>
    <input/>
    <output/>
    <macros/>
    </context>
    <operator activated="true" class="process" compatibility="8.0.001" expanded="true" name="Process">
    <process expanded="true">
    <operator activated="true" class="read_csv" compatibility="8.0.001" expanded="true" height="68" name="Read CSV" width="90" x="112" y="136">
    <parameter key="csv_file" value="C:\Users\Martin\Desktop\0_Hotel_Review_Data.csv"/>
    <parameter key="column_separators" value=","/>
    <parameter key="first_row_as_names" value="false"/>
    <list key="annotations">
    <parameter key="0" value="Name"/>
    </list>
    <parameter key="encoding" value="windows-1252"/>
    <list key="data_set_meta_data_information">
    <parameter key="0" value="Text.true.polynominal.attribute"/>
    <parameter key="1" value="Rating.true.real.attribute"/>
    <parameter key="2" value="ReviewId.true.real.attribute"/>
    </list>
    </operator>
    <operator activated="true" class="annotations_to_data" compatibility="8.0.001" expanded="true" height="82" name="Annotations to Data" width="90" x="246" y="136"/>
    <operator activated="true" class="filter_examples" compatibility="8.0.001" expanded="true" height="103" name="Filter Examples" width="90" x="380" y="34">
    <list key="filters_list">
    <parameter key="filters_entry_key" value="annotation.equals.Source"/>
    </list>
    </operator>
    <operator activated="true" class="extract_macro" compatibility="8.0.001" expanded="true" height="68" name="Extract Macro" width="90" x="581" y="34">
    <parameter key="macro" value="Source"/>
    <parameter key="macro_type" value="data_value"/>
    <parameter key="attribute_name" value="value"/>
    <parameter key="example_index" value="1"/>
    <list key="additional_macros"/>
    </operator>
    <operator activated="true" class="delay" compatibility="8.0.001" expanded="true" height="103" name="Delay" width="90" x="715" y="85">
    <parameter key="delay_amount" value="0"/>
    <description align="center" color="transparent" colored="false" width="126">Only to ensure execution order</description>
    </operator>
    <operator activated="true" class="generate_attributes" compatibility="8.0.001" expanded="true" height="82" name="Generate Attributes" width="90" x="849" y="136">
    <list key="function_descriptions">
    <parameter key="Source" value="%{source}"/>
    </list>
    </operator>
    <connect from_op="Read CSV" from_port="output" to_op="Annotations to Data" to_port="object"/>
    <connect from_op="Annotations to Data" from_port="annotations" to_op="Filter Examples" to_port="example set input"/>
    <connect from_op="Annotations to Data" from_port="object through" to_op="Delay" to_port="through 2"/>
    <connect from_op="Filter Examples" from_port="example set output" to_op="Extract Macro" to_port="example set"/>
    <connect from_op="Extract Macro" from_port="example set" to_op="Delay" to_port="through 1"/>
    <connect from_op="Delay" from_port="through 1" to_port="result 1"/>
    <connect from_op="Delay" from_port="through 2" to_op="Generate Attributes" to_port="example set input"/>
    <connect from_op="Generate Attributes" from_port="example set output" to_port="result 2"/>
    <portSpacing port="source_input 1" spacing="0"/>
    <portSpacing port="sink_result 1" spacing="0"/>
    <portSpacing port="sink_result 2" spacing="0"/>
    <portSpacing port="sink_result 3" spacing="0"/>
    </process>
    </operator>
    </process>
    - Head of Data Science Services at RapidMiner -
    Dortmund, Germany
    BalazsBaranysgenzer
  • oliver23oliver23 Member Posts: 4 Contributor I

    Thanks!

Sign In or Register to comment.