How to assign number of examples as a macro value in create example set operator.
hbajpai
New Altair Community Member
So, I have a problem statement in which total examples for create example set operators are variable and I am trying to assign them through a macro input. However, I believe the create example set operator does not take marcos as input. Please see the below snapshot of the process.
1
Best Answer
-
Hello @hbajpai
Thanks for sharing the process. I replicated this error. The issue is that the macro is generating a float value with .0 at the end. I just used ceil(eval(%{macro_name})) and it works as it is rounded off to a nearest integer.<?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_macro" compatibility="9.6.000" expanded="true" height="68" name="Generate Macro" width="90" x="581" y="136"> <list key="function_descriptions"> <parameter key="total_10min" value="1 - date_diff(date_parse_custom("03/22/2020 10:00:00 PM","MM/dd/yyyy hh:mm:ss aa"), 				date_parse_custom("01/22/2020 10:00:00 PM","MM/dd/yyyy hh:mm:ss aa"))/600000"/> <parameter key="total_10min_1" value="ceil(eval(%{total_10min}))"/> </list> </operator> <operator activated="true" class="utility:create_exampleset" compatibility="9.6.000" expanded="true" height="68" name="Create ExampleSet" width="90" x="849" y="34"> <parameter key="generator_type" value="date series"/> <parameter key="number_of_examples" value="%{total_10min_1}"/> <parameter key="use_stepsize" value="true"/> <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="TimeStamp" value="2010-11-12 18:10:00 PM.10.minute"/> </list> <parameter key="date_format" value="yyyy-MM-dd HH:mm:ss"/> <parameter key="time_zone" value="SYSTEM"/> <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> <connect from_op="Create ExampleSet" from_port="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>
Do let us know if this works for you?
Hope this helps
1
Answers
-
Hello @hbajpai
I tried using set macro with a value of 100 and macro name as "name". Then I used create exampleset where I called that macro %{name} in the number of examples and it worked. Can you check your macro is returning a value (number)? You can check this by enabling macro window in View --> Show Panel --> Macros. Try to set a breakpoint before create exampleset by right-clicking on it and run it to check macro value.
Do let us know if you need more information.0 -
@varunm1 In the standalone cases, I have tried too and it works as you demonstrated in the above example. In my situation, the macro is returning a number, I even used eval() to ensure it. I have attached the XML code of the mock process to demonstrate the error.
<?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_macro" compatibility="9.6.000" expanded="true" height="68" name="Generate Macro" width="90" x="581" y="136"> <list key="function_descriptions"> <parameter key="total_10min" value="1 - date_diff(date_parse_custom("03/22/2020 10:00:00 PM","MM/dd/yyyy hh:mm:ss aa"), 				date_parse_custom("01/22/2020 10:00:00 PM","MM/dd/yyyy hh:mm:ss aa"))/600000"/> <parameter key="total_10min_1" value="eval(%{total_10min})"/> </list> </operator> <operator activated="true" class="utility:create_exampleset" compatibility="9.6.000" expanded="true" height="68" name="Create ExampleSet" width="90" x="849" y="34"> <parameter key="generator_type" value="date series"/> <parameter key="number_of_examples" value="%{total_10min_1}"/> <parameter key="use_stepsize" value="true"/> <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="TimeStamp" value="2010-11-12 18:10:00 PM.10.minute"/> </list> <parameter key="date_format" value="yyyy-MM-dd HH:mm:ss"/> <parameter key="time_zone" value="SYSTEM"/> <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> <connect from_op="Create ExampleSet" from_port="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>
0 -
Hello @hbajpai
Thanks for sharing the process. I replicated this error. The issue is that the macro is generating a float value with .0 at the end. I just used ceil(eval(%{macro_name})) and it works as it is rounded off to a nearest integer.<?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_macro" compatibility="9.6.000" expanded="true" height="68" name="Generate Macro" width="90" x="581" y="136"> <list key="function_descriptions"> <parameter key="total_10min" value="1 - date_diff(date_parse_custom("03/22/2020 10:00:00 PM","MM/dd/yyyy hh:mm:ss aa"), 				date_parse_custom("01/22/2020 10:00:00 PM","MM/dd/yyyy hh:mm:ss aa"))/600000"/> <parameter key="total_10min_1" value="ceil(eval(%{total_10min}))"/> </list> </operator> <operator activated="true" class="utility:create_exampleset" compatibility="9.6.000" expanded="true" height="68" name="Create ExampleSet" width="90" x="849" y="34"> <parameter key="generator_type" value="date series"/> <parameter key="number_of_examples" value="%{total_10min_1}"/> <parameter key="use_stepsize" value="true"/> <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="TimeStamp" value="2010-11-12 18:10:00 PM.10.minute"/> </list> <parameter key="date_format" value="yyyy-MM-dd HH:mm:ss"/> <parameter key="time_zone" value="SYSTEM"/> <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> <connect from_op="Create ExampleSet" from_port="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>
Do let us know if this works for you?
Hope this helps
1