"Replace (Dictionary) operator not working"
Richy
New Altair Community Member
Hi,
I'm trying to use the replace (dictionary) operator, but I cant make it works. I'm setting the type to "text" so I shouldn't have any problem (I also tried with nominal type).
My problem is it doesn't replace any value. I also tried the replace operator using regular expression to replace "-1" by "test" and it's working very well.
Would you have any idea?
Here is my code :
Regards,
Richard.
I'm trying to use the replace (dictionary) operator, but I cant make it works. I'm setting the type to "text" so I shouldn't have any problem (I also tried with nominal type).
My problem is it doesn't replace any value. I also tried the replace operator using regular expression to replace "-1" by "test" and it's working very well.
Would you have any idea?
Here is my code :
<?xml version="1.0" encoding="UTF-8" standalone="no"?>And my .csv file :
<process version="5.0">
<context>
<input/>
<output/>
<macros/>
</context>
<operator activated="true" class="process" compatibility="5.0.11" expanded="true" name="Process">
<process expanded="true" height="425" width="822">
<operator activated="true" class="generate_data" compatibility="5.0.11" expanded="true" height="60" name="Generate Data" width="90" x="45" y="30">
<parameter key="number_of_attributes" value="1"/>
<parameter key="datamanagement" value="int_array"/>
</operator>
<operator activated="true" class="numerical_to_polynominal" compatibility="5.0.11" expanded="true" height="76" name="Numerical to Polynominal (2)" width="90" x="179" y="30">
<parameter key="attribute_filter_type" value="single"/>
<parameter key="attribute" value="att1"/>
</operator>
<operator activated="true" class="nominal_to_text" compatibility="5.0.11" expanded="true" height="76" name="Nominal to Text" width="90" x="313" y="30"/>
<operator activated="true" class="read_csv" compatibility="5.0.11" expanded="true" height="60" name="Read CSV" width="90" x="45" y="120">
<parameter key="file_name" value="file:/D:/datamining/Scripts/rename.csv"/>
<list key="data_set_meta_data_information"/>
</operator>
<operator activated="true" class="numerical_to_polynominal" compatibility="5.0.11" expanded="true" height="76" name="Numerical to Polynominal" width="90" x="179" y="120"/>
<operator activated="true" class="nominal_to_text" compatibility="5.0.11" expanded="true" height="76" name="Nominal to Text (2)" width="90" x="313" y="120"/>
<operator activated="true" class="replace_dictionary" compatibility="5.0.11" expanded="true" height="94" name="Replace (Dictionary)" width="90" x="447" y="30">
<parameter key="attribute_filter_type" value="single"/>
<parameter key="attribute" value="att1"/>
<parameter key="from_attribute" value="old_value"/>
<parameter key="to_attribute" value="new_value"/>
<parameter key="use_regular_expressions" value="true"/>
</operator>
<connect from_op="Generate Data" from_port="output" to_op="Numerical to Polynominal (2)" to_port="example set input"/>
<connect from_op="Numerical to Polynominal (2)" from_port="example set output" to_op="Nominal to Text" to_port="example set input"/>
<connect from_op="Nominal to Text" from_port="example set output" to_op="Replace (Dictionary)" to_port="example set input"/>
<connect from_op="Read CSV" from_port="output" to_op="Numerical to Polynominal" to_port="example set input"/>
<connect from_op="Numerical to Polynominal" from_port="example set output" to_op="Nominal to Text (2)" to_port="example set input"/>
<connect from_op="Nominal to Text (2)" from_port="example set output" to_op="Replace (Dictionary)" to_port="dictionary"/>
<portSpacing port="source_input 1" spacing="0"/>
<portSpacing port="sink_result 1" spacing="0"/>
</process>
</operator>
</process>
old_value;new_value
-10;first
-9;first
-8;first
-7;first
-6;first
-5;first
-4;first
-3;first
-2;second
-1;second
0;second
1;second
2;second
3;second
4;second
5;third
6;third
7;third
8;third
9;third
10;third
Regards,
Richard.
Tagged:
0
Answers
-
Hi,
you need to switch of treating "-1" as regular expression or you will have to escape "-".
Just turn the parameter "use_regular_expression" off and it will work.
Greetings,
Sebastian0 -
Hi,
Thank you for the fast reply. I tried to turn the parameter "use_regular_expression" off, but it doesn't change anything.
Regards,
Richard.0 -
Hi,
your process does work as you posted on the current developer version. So I guess you simply have to wait for the next update.
Greetings,
Sebastian0 -
Hi,
I just updated rapidminer to the new version (5.1) and it's working well.
Regards,
Richard.0