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
Generate a Function & apply it to all/some attributes automatically
I've created a new attribute using the Generate Attribute operator.
Attribute name N_speed, with 'N' representing the location.
E.g. 2_speed represents speed at location 2.
(New) Attribute Name: 2speed
Function Expressions: if([2_speed]>=70,"DANGER","SAFE").
However, I have nearly 300 attributes. I've tried adding new entries and replacing each with the name of the next attribute, but its just too much work.
Hence, Is there any way to apply the same function to all attributes automatically?
if([2_speed]>=70,"DANGER","SAFE")
if([3_speed]>=70,"DANGER","SAFE")
if([4_speed]>=70,"DANGER","SAFE")
if([5_speed]>=70,"DANGER","SAFE")
if([6_speed]>=70,"DANGER","SAFE")
if([7_speed]>=70,"DANGER","SAFE") and so on...
Thanks.
Regards,
AY
Attribute name N_speed, with 'N' representing the location.
E.g. 2_speed represents speed at location 2.
(New) Attribute Name: 2speed
Function Expressions: if([2_speed]>=70,"DANGER","SAFE").
However, I have nearly 300 attributes. I've tried adding new entries and replacing each with the name of the next attribute, but its just too much work.
Hence, Is there any way to apply the same function to all attributes automatically?
if([2_speed]>=70,"DANGER","SAFE")
if([3_speed]>=70,"DANGER","SAFE")
if([4_speed]>=70,"DANGER","SAFE")
if([5_speed]>=70,"DANGER","SAFE")
if([6_speed]>=70,"DANGER","SAFE")
if([7_speed]>=70,"DANGER","SAFE") and so on...
Thanks.
Regards,
AY
Tagged:
0
Best Answers
-
MartinLiebig Administrator, Moderator, Employee-RapidMiner, RapidMiner Certified Analyst, RapidMiner Certified Expert, University Professor Posts: 3,533 RM Data ScientistHi,
Loop attributes is your friend .
BR,
Martin
- Sr. Director Data Solutions, Altair RapidMiner -
Dortmund, Germany5 -
lionelderkrikor RapidMiner Certified Analyst, Member Posts: 1,195 UnicornHi @1705410G,
You have to put the Generate Attributes operator inside the Loop Attributes operator :
Here a process to show you how to proceed :<?xml version="1.0" encoding="UTF-8"?><process version="9.2.000-SNAPSHOT"> <context> <input/> <output/> <macros/> </context> <operator activated="true" class="process" compatibility="9.2.000-SNAPSHOT" 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="operator_toolbox:create_exampleset" compatibility="1.7.000" expanded="true" height="68" name="Create ExampleSet" width="90" x="112" y="136"> <parameter key="generator_type" value="numeric_series"/> <parameter key="number_of_examples" value="10"/> <parameter key="use_stepsize" value="false"/> <list key="function_descriptions"/> <parameter key="add_id_attribute" value="false"/> <list key="numeric_series_configuration"> <parameter key="att_1" value="linear.0\.0.10\.0"/> <parameter key="att_2" value="linear.10\.0.20\.0"/> </list> <list key="date_series_configuration"/> <list key="date_series_configuration (interval)"/> <parameter key="date_format" value="yyyy-MM-dd HH:mm:ss"/> <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="concurrency:loop_attributes" compatibility="9.2.000-SNAPSHOT" expanded="true" height="82" name="Loop Attributes" width="90" x="380" y="136"> <parameter key="attribute_filter_type" value="all"/> <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="attribute_name_macro" value="loop_attribute"/> <parameter key="reuse_results" value="true"/> <parameter key="enable_parallel_execution" value="true"/> <process expanded="true"> <operator activated="true" class="generate_attributes" compatibility="9.2.000-SNAPSHOT" expanded="true" height="82" name="Generate Attributes" width="90" x="313" y="85"> <list key="function_descriptions"> <parameter key="%{loop_attribute}_bis" value="if(eval(%{loop_attribute})>5,"true","false")"/> </list> <parameter key="keep_all" value="true"/> </operator> <connect from_port="input 1" to_op="Generate Attributes" to_port="example set input"/> <connect from_op="Generate Attributes" 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_op="Create ExampleSet" from_port="output" to_op="Loop Attributes" to_port="input 1"/> <connect from_op="Loop Attributes" from_port="output 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>
Hope it helps,
Regards,
Lionel
6 -
Telcontar120 RapidMiner Certified Analyst, RapidMiner Certified Expert, Member Posts: 1,635 Unicornif you are using Loop Attributes, you should be referring to the attribute being handled via the associated macro, and this should clear up the problem that you were having with the EVAL function error. That macro is bound to the operator so you don't have to enable anything to get it (but you do need to fill in the name you want to use in the parameters).5
-
Telcontar120 RapidMiner Certified Analyst, RapidMiner Certified Expert, Member Posts: 1,635 UnicornThis is really hard to troubleshoot without data, but you could try the #{loop_attribute} macro syntax instead of eval(%{loop_attribute}) and see if that solves your problem.5
Answers
Hi! I tried using it earlier on, but failed.
Hence, What are the Parameters of Loop Attributes I should make changes to?
How can I insert the function expression?
Regards,
AY
Do I have to change the attribute name and function to my own attribute name or should I leave it to what you've provided me?
As I kept getting this error inside the Generate Attribute operator.
Expression Evaluation Error: The function 'eval' failed to parse the subexpression '2_speed'. Cause: token recognition error at '_'
And how do I make an exception for my date_time? So that it wouldn't be involved in any looping?
P.S. I've also changed my function to if(([2_speed]<=35),"LOW",if(([2_speed]<=53),"MODERATE",if(([2_speed]<=70),"HIGH","VERY HIGH"))) instead. How should I insert it?
Regards,
AY
Also, after pasting it in the process, I do not have the loop_attribute macro (inside Generate Attribute) as compared to pasting it into a brand new process. Does it matter?
Regards,
AY
Sorry, I don't get what you mean. I followed the steps shown in the video below but the error stills occur.
Expression Evaluation Error: The function 'eval' failed to parse the subexpression '2_speed'. Cause: token recognition error at '_' .
Does it mean that I have to remove the underscore used in all my attributes' name?
Video Reference: https://academy.rapidminer.com/learn/video/loop-attributes
Regards,
AY
Sorry, but I won't be able to share any dataset and process as it is school related.
However, what I has is 2 Loop Attributes Operator, each containing a Generate Attribute Operator.
Attribute Name(Inside Generate Attribute) for both Loop Attributes Operator: %{loop_attribute}
Function for 1st Loop Attributes Operator: if((eval(%{loop_attribute})<=35),"LOW",if((eval(%{loop_attribute})<=53),"MODERATE",if((eval(%{loop_attribute})<=70),"HIGH","VERY HIGH")))
Function for 1st Loop Attributes Operator: if((eval(%{loop_attribute})<=35),"LOW",if((eval(%{loop_attribute})<=53),"MODERATE",if((eval(%{loop_attribute})<=70),"HIGH","VERY HIGH")))
This are the errors I've been receiving (Shown in below).
But I've selected subset in attribute filter type. Iterations should not have been 0.
I am very confused. Once I solved the first error, second error pops up. Solved it, first error back again and vice versa. I've changed my naming countless times, with underscore to no underscore, numbers (10) to spelling (ten).
I have no idea what went wrong.
Hope this can help you better analyse!
Regards,
AY
Hi! I tried using it earlier on, but failed.
Hence, What are the Parameters of Loop Attributes I should make changes to?
Regards,
AY
Do I have to change the attribute name and function inside the Generate Attribute operator to my own attribute name or should I leave it to what you've provided me?
As I kept getting this error inside the Generate Attribute operator.
Expression Evaluation Error: The function 'eval' failed to parse the subexpression '2_speed'. Cause: token recognition error at '_'
Regards,
AY
Just to add on, how do I copy your codes into my process without removing my other existing operators? As I can only paste into a new process.
Regards,
AY
Sorry, but I won't be able to share any dataset and process as it is school related.
However, what I has is 2 Loop Attributes Operator, each containing a Generate Attribute Operator.
Attribute Name(Inside Generate Attribute) for both Loop Attributes Operator: %{loop_attribute}
Function for 1st Loop Attributes Operator: if((eval(%{loop_attribute})<=35),"LOW",if((eval(%{loop_attribute})<=53),"MODERATE",if((eval(%{loop_attribute})<=70),"HIGH","VERY HIGH")))
Function for 1st Loop Attributes Operator: if((eval(%{loop_attribute})<=35),"LOW",if((eval(%{loop_attribute})<=53),"MODERATE",if((eval(%{loop_attribute})<=70),"HIGH","VERY HIGH")))
This are the errors I've been receiving (Shown in below).
But I've selected subset in attribute filter type. Iterations should not have been 0.
I am very confused. Once I solved the first error, second error pops up. Solved it, first error back again and vice versa. I've changed my naming countless times, with underscore to no underscore, numbers (10) to spelling (ten).
I have no idea what went wrong.
Regards,
AY
Hi! I tried using it earlier on, but failed.
Hence, What are the Parameters of Loop Attributes I should make changes to?
Regards,
AY
Do I have to change the attribute name and function inside the Generate Attribute operator to my own attribute name or should I leave it to what you've provided me?
As I kept getting this error inside the Generate Attribute operator.
Expression Evaluation Error: The function 'eval' failed to parse the subexpression '2_speed'. Cause: token recognition error at '_'
Regards,
AY
Just to add on, how do I copy your codes into my process without removing my other existing operators? As I can only paste into a new process.
Regards,
AY