The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here
Easiest way to remove "count" in front of attribute name
Best Answers
-
hbajpai Member Posts: 102 UnicornHey @jhiKl,
You can use rename by replacing operator. Let's say this is the input:
The output will be:
The XML code for the same process is:<?xml version="1.0" encoding="UTF-8"?><process version="9.6.000"> <context> <input/> <output/> <macros/> </context> <operator activated="true" class="process" compatibility="9.6.000" 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="SYSTEM"/> <process expanded="true"> <operator activated="true" class="generate_data" compatibility="9.6.000" expanded="true" height="68" name="Generate Data" width="90" x="581" y="34"> <parameter key="target_function" value="random"/> <parameter key="number_examples" value="100"/> <parameter key="number_of_attributes" value="5"/> <parameter key="attributes_lower_bound" value="-10.0"/> <parameter key="attributes_upper_bound" value="10.0"/> <parameter key="gaussian_standard_deviation" value="10.0"/> <parameter key="largest_radius" value="10.0"/> <parameter key="use_local_random_seed" value="false"/> <parameter key="local_random_seed" value="1992"/> <parameter key="datamanagement" value="double_array"/> <parameter key="data_management" value="auto"/> </operator> <operator activated="true" breakpoints="after" class="rename" compatibility="9.6.000" expanded="true" height="82" name="Rename" width="90" x="715" y="34"> <parameter key="old_name" value="att1"/> <parameter key="new_name" value="count (prod_name)_sunglasses"/> <list key="rename_additional_attributes"> <parameter key="att2" value="count (prod_name)_rayban"/> </list> </operator> <operator activated="true" class="subprocess" compatibility="9.6.000" expanded="true" height="82" name="Rename by replacing block" width="90" x="916" y="34"> <process expanded="true"> <operator activated="true" class="rename_by_replacing" compatibility="9.6.000" expanded="true" height="82" name="Rename by Replacing" width="90" x="45" y="34"> <parameter key="attribute_filter_type" value="subset"/> <parameter key="attribute" value=""/> <parameter key="attributes" value="count (prod_name)_rayban|count (prod_name)_sunglasses"/> <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="false"/> <parameter key="include_special_attributes" value="false"/> <parameter key="replace_what" value="count"/> <parameter key="replace_by" value=""/> </operator> <operator activated="true" class="rename_by_replacing" compatibility="9.6.000" expanded="true" height="82" name="Rename by Replacing (2)" width="90" x="179" y="34"> <parameter key="attribute_filter_type" value="subset"/> <parameter key="attribute" value=""/> <parameter key="attributes" value=" (prod_name)_rayban| (prod_name)_sunglasses"/> <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="false"/> <parameter key="include_special_attributes" value="false"/> <parameter key="replace_what" value="[_()]"/> <parameter key="replace_by" value=""/> </operator> <operator activated="true" class="rename_by_replacing" compatibility="9.6.000" expanded="true" height="82" name="Rename by Replacing (3)" width="90" x="313" y="34"> <parameter key="attribute_filter_type" value="subset"/> <parameter key="attribute" value=""/> <parameter key="attributes" value=" prodnamerayban| prodnamesunglasses"/> <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="false"/> <parameter key="include_special_attributes" value="false"/> <parameter key="replace_what" value="prodname"/> </operator> <connect from_port="in 1" to_op="Rename by Replacing" to_port="example set input"/> <connect from_op="Rename by Replacing" from_port="example set output" to_op="Rename by Replacing (2)" to_port="example set input"/> <connect from_op="Rename by Replacing (2)" from_port="example set output" to_op="Rename by Replacing (3)" to_port="example set input"/> <connect from_op="Rename by Replacing (3)" from_port="example set output" 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> <connect from_op="Generate Data" from_port="output" to_op="Rename" to_port="example set input"/> <connect from_op="Rename" from_port="example set output" to_op="Rename by replacing block" to_port="in 1"/> <connect from_op="Rename by replacing block" 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>
Best,
Harshit7 -
MarcoBarradas Administrator, Employee-RapidMiner, RapidMiner Certified Analyst, Member Posts: 272 Unicorn@jhiKl this is the regex you need
Let me explain- .* matches all the characters before the (
- \( escapes the "(" you are trying to find
- (\w+) tells that you want to capture all the word characters \w+ until the next rule
- Please notice the difference when you try to find a "(" =\( from when you are trying to capture something () there is no use of \
- \) tells the regex that it need to stop capturing when it finds a ")"
.*\((\w+)\)
and you need to put on the replace the$1 makes reference to the capture group$1
9
Answers
If you can share your XML I quickly try and send you updates process.
Harshit
<context>
<input/>
<output/>
<macros/>
</context>
<operator activated="true" class="process" compatibility="9.6.000" 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="SYSTEM"/>
<process expanded="true">
<operator activated="true" class="retrieve" compatibility="9.6.000" expanded="true" height="68" name="Retrieve JANMarketAnalysis1997" width="90" x="45" y="187">
<parameter key="repository_entry" value="//IS210 Case Analysis/data/JANMarketAnalysis1997"/>
</operator>
<operator activated="true" class="rename_by_replacing" compatibility="9.6.000" expanded="true" height="82" name="Rename by Replacing" width="90" x="179" y="187">
<parameter key="attribute_filter_type" value="subset"/>
<parameter key="attribute" value=""/>
<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="false"/>
<parameter key="include_special_attributes" value="false"/>
<parameter key="replace_what" value="\W"/>
</operator>
<connect from_op="Retrieve JANMarketAnalysis1997" from_port="output" to_op="Rename by Replacing" to_port="example set input"/>
<connect from_op="Rename by Replacing" 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>
Appreciatively,
jhiKl