Due to recent updates, all users are required to create an Altair One account to login to the RapidMiner community. Click the Register button to create your account using the same email that you have previously used to login to the RapidMiner community. This will ensure that any previously created content will be synced to your Altair One account. Once you login, you will be asked to provide a username that identifies you to other Community users. Email us at Community with questions.
Compare date-macros in a Branch Operator
Hello everybody.
I´m having some problems with a process im trying to build.
So I want to check an existing table (that get´s updated through a scheduler) in my repository for updates, and if there is one, I want another process to start. If there is no update to it, then nothing happens.
To do so, I want to use the Branch-Operator, and the condition of it compares the latest entry of the table to the current date. Unfortunately the results are simply not right.
I saved the most recent date in the table as a macro, the current date also as a macro.
My question now is, how this problem should be entered into the "expression" window in the Branch operator?
I´d be very grateful for your help!
Best,
Richard
<?xml version="1.0" encoding="UTF-8"?><process version="9.5.000">
<context>
<input/>
<output/>
<macros/>
</context>
<operator activated="true" class="process" compatibility="9.5.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.5.000" expanded="true" height="68" name="Retrieve xy data (2)" width="90" x="45" y="34">
<parameter key="repository_entry" value="../data/xy data"/>
</operator>
<operator activated="true" class="nominal_to_date" compatibility="9.5.000" expanded="true" height="82" name="Nominal to Date" width="90" x="179" y="34">
<parameter key="attribute_name" value="Erstellt"/>
<parameter key="date_type" value="date_time"/>
<parameter key="date_format" value="dd.MM.yyyy HH:mm"/>
<parameter key="time_zone" value="SYSTEM"/>
<parameter key="locale" value="English (United States)"/>
<parameter key="keep_old_attribute" value="false"/>
</operator>
<operator activated="true" class="sort" compatibility="9.5.000" expanded="true" height="82" name="Sort" width="90" x="313" y="34">
<parameter key="attribute_name" value="Erstellt"/>
<parameter key="sorting_direction" value="decreasing"/>
</operator>
<operator activated="false" class="date_to_nominal" compatibility="9.5.000" expanded="true" height="82" name="Date to Nominal" width="90" x="447" y="136">
<parameter key="attribute_name" value="Erstellt"/>
<parameter key="date_format" value="dd.MM.yyyy HH:MM"/>
<parameter key="time_zone" value="SYSTEM"/>
<parameter key="locale" value="English (United States)"/>
<parameter key="keep_old_attribute" value="false"/>
</operator>
<operator activated="true" class="extract_macro" compatibility="9.5.000" expanded="true" height="68" name="Extract Macro" width="90" x="648" y="34">
<parameter key="macro" value="Date"/>
<parameter key="macro_type" value="data_value"/>
<parameter key="statistics" value="average"/>
<parameter key="attribute_name" value="Erstellt"/>
<parameter key="example_index" value="1"/>
<list key="additional_macros"/>
</operator>
<operator activated="true" breakpoints="after" class="generate_macro" compatibility="9.5.000" expanded="true" height="82" name="Generate Macro" width="90" x="782" y="34">
<list key="function_descriptions">
<parameter key="Current Date" value="date_now()"/>
</list>
</operator>
<operator activated="true" class="branch" compatibility="9.5.000" expanded="true" height="82" name="Branch" width="90" x="916" y="34">
<parameter key="condition_type" value="expression"/>
<parameter key="expression" value="%{Date}>%{Current Date}"/>
<parameter key="io_object" value="ANOVAMatrix"/>
<parameter key="return_inner_output" value="true"/>
<process expanded="true">
<operator activated="true" class="productivity:execute_process" compatibility="9.5.000" expanded="true" height="82" name="Execute xy" width="90" x="179" y="34">
<parameter key="process_location" value="../../../xy"/>
<parameter key="use_input" value="true"/>
<parameter key="store_output" value="false"/>
<parameter key="propagate_metadata_recursively" value="true"/>
<parameter key="cache_process" value="true"/>
<list key="macros"/>
<parameter key="fail_for_unknown_macros" value="true"/>
</operator>
<connect from_port="condition" to_op="Execute xy" to_port="input 1"/>
<connect from_op="Execute xy" from_port="result 1" to_port="input 1"/>
<portSpacing port="source_condition" spacing="0"/>
<portSpacing port="source_input 1" spacing="0"/>
<portSpacing port="sink_input 1" spacing="0"/>
<portSpacing port="sink_input 2" spacing="0"/>
</process>
<process expanded="true">
<operator activated="true" class="throw_exception" compatibility="9.5.000" expanded="true" height="82" name="Throw Exception" width="90" x="179" y="34">
<parameter key="message" value="oh no!"/>
</operator>
<connect from_port="condition" to_op="Throw Exception" to_port="through 1"/>
<connect from_op="Throw Exception" from_port="through 1" to_port="input 1"/>
<portSpacing port="source_condition" spacing="0"/>
<portSpacing port="source_input 1" spacing="0"/>
<portSpacing port="sink_input 1" spacing="0"/>
<portSpacing port="sink_input 2" spacing="0"/>
</process>
</operator>
<connect from_op="Retrieve xy data (2)" from_port="output" to_op="Nominal to Date" to_port="example set input"/>
<connect from_op="Nominal to Date" from_port="example set output" to_op="Sort" to_port="example set input"/>
<connect from_op="Sort" from_port="example set output" to_op="Extract Macro" to_port="example set"/>
<connect from_op="Extract Macro" from_port="example set" to_op="Generate Macro" to_port="through 1"/>
<connect from_op="Generate Macro" from_port="through 1" to_op="Branch" to_port="condition"/>
<connect from_op="Branch" from_port="input 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>
<context>
<input/>
<output/>
<macros/>
</context>
<operator activated="true" class="process" compatibility="9.5.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.5.000" expanded="true" height="68" name="Retrieve xy data (2)" width="90" x="45" y="34">
<parameter key="repository_entry" value="../data/xy data"/>
</operator>
<operator activated="true" class="nominal_to_date" compatibility="9.5.000" expanded="true" height="82" name="Nominal to Date" width="90" x="179" y="34">
<parameter key="attribute_name" value="Erstellt"/>
<parameter key="date_type" value="date_time"/>
<parameter key="date_format" value="dd.MM.yyyy HH:mm"/>
<parameter key="time_zone" value="SYSTEM"/>
<parameter key="locale" value="English (United States)"/>
<parameter key="keep_old_attribute" value="false"/>
</operator>
<operator activated="true" class="sort" compatibility="9.5.000" expanded="true" height="82" name="Sort" width="90" x="313" y="34">
<parameter key="attribute_name" value="Erstellt"/>
<parameter key="sorting_direction" value="decreasing"/>
</operator>
<operator activated="false" class="date_to_nominal" compatibility="9.5.000" expanded="true" height="82" name="Date to Nominal" width="90" x="447" y="136">
<parameter key="attribute_name" value="Erstellt"/>
<parameter key="date_format" value="dd.MM.yyyy HH:MM"/>
<parameter key="time_zone" value="SYSTEM"/>
<parameter key="locale" value="English (United States)"/>
<parameter key="keep_old_attribute" value="false"/>
</operator>
<operator activated="true" class="extract_macro" compatibility="9.5.000" expanded="true" height="68" name="Extract Macro" width="90" x="648" y="34">
<parameter key="macro" value="Date"/>
<parameter key="macro_type" value="data_value"/>
<parameter key="statistics" value="average"/>
<parameter key="attribute_name" value="Erstellt"/>
<parameter key="example_index" value="1"/>
<list key="additional_macros"/>
</operator>
<operator activated="true" breakpoints="after" class="generate_macro" compatibility="9.5.000" expanded="true" height="82" name="Generate Macro" width="90" x="782" y="34">
<list key="function_descriptions">
<parameter key="Current Date" value="date_now()"/>
</list>
</operator>
<operator activated="true" class="branch" compatibility="9.5.000" expanded="true" height="82" name="Branch" width="90" x="916" y="34">
<parameter key="condition_type" value="expression"/>
<parameter key="expression" value="%{Date}>%{Current Date}"/>
<parameter key="io_object" value="ANOVAMatrix"/>
<parameter key="return_inner_output" value="true"/>
<process expanded="true">
<operator activated="true" class="productivity:execute_process" compatibility="9.5.000" expanded="true" height="82" name="Execute xy" width="90" x="179" y="34">
<parameter key="process_location" value="../../../xy"/>
<parameter key="use_input" value="true"/>
<parameter key="store_output" value="false"/>
<parameter key="propagate_metadata_recursively" value="true"/>
<parameter key="cache_process" value="true"/>
<list key="macros"/>
<parameter key="fail_for_unknown_macros" value="true"/>
</operator>
<connect from_port="condition" to_op="Execute xy" to_port="input 1"/>
<connect from_op="Execute xy" from_port="result 1" to_port="input 1"/>
<portSpacing port="source_condition" spacing="0"/>
<portSpacing port="source_input 1" spacing="0"/>
<portSpacing port="sink_input 1" spacing="0"/>
<portSpacing port="sink_input 2" spacing="0"/>
</process>
<process expanded="true">
<operator activated="true" class="throw_exception" compatibility="9.5.000" expanded="true" height="82" name="Throw Exception" width="90" x="179" y="34">
<parameter key="message" value="oh no!"/>
</operator>
<connect from_port="condition" to_op="Throw Exception" to_port="through 1"/>
<connect from_op="Throw Exception" from_port="through 1" to_port="input 1"/>
<portSpacing port="source_condition" spacing="0"/>
<portSpacing port="source_input 1" spacing="0"/>
<portSpacing port="sink_input 1" spacing="0"/>
<portSpacing port="sink_input 2" spacing="0"/>
</process>
</operator>
<connect from_op="Retrieve xy data (2)" from_port="output" to_op="Nominal to Date" to_port="example set input"/>
<connect from_op="Nominal to Date" from_port="example set output" to_op="Sort" to_port="example set input"/>
<connect from_op="Sort" from_port="example set output" to_op="Extract Macro" to_port="example set"/>
<connect from_op="Extract Macro" from_port="example set" to_op="Generate Macro" to_port="through 1"/>
<connect from_op="Generate Macro" from_port="through 1" to_op="Branch" to_port="condition"/>
<connect from_op="Branch" from_port="input 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>
Tagged:
0
Best Answer
-
MartinLiebig Administrator, Moderator, Employee, RapidMiner Certified Analyst, RapidMiner Certified Expert, University Professor Posts: 3,531 RM Data ScientistHi @RichL ,checkout the attached process. That explains it well i guess. You can use the normal Extract Macro and not Extract Macro (Format) of Toolbox extension, but then the parsing equation gets more complex.Cheers!Martin
<?xml version="1.0" encoding="UTF-8"?><process version="9.5.000"><br> <context><br> <input/><br> <output/><br> <macros/><br> </context><br> <operator activated="true" class="process" compatibility="9.5.000" expanded="true" name="Process"><br> <parameter key="logverbosity" value="init"/><br> <parameter key="random_seed" value="2001"/><br> <parameter key="send_mail" value="never"/><br> <parameter key="notification_email" value=""/><br> <parameter key="process_duration_for_mail" value="30"/><br> <parameter key="encoding" value="SYSTEM"/><br> <process expanded="true"><br> <operator activated="true" class="utility:create_exampleset" compatibility="9.5.000" expanded="true" height="68" name="Create ExampleSet" width="90" x="45" y="34"><br> <parameter key="generator_type" value="date series"/><br> <parameter key="number_of_examples" value="100"/><br> <parameter key="use_stepsize" value="false"/><br> <list key="function_descriptions"/><br> <parameter key="add_id_attribute" value="false"/><br> <list key="numeric_series_configuration"/><br> <list key="date_series_configuration"><br> <parameter key="Erstellt" value="2019-01-01 00:00:00.2020-01-01 00:00:00"/><br> </list><br> <list key="date_series_configuration (interval)"/><br> <parameter key="date_format" value="yyyy-MM-dd HH:mm:ss"/><br> <parameter key="time_zone" value="SYSTEM"/><br> <parameter key="column_separator" value=","/><br> <parameter key="parse_all_as_nominal" value="false"/><br> <parameter key="decimal_point_character" value="."/><br> <parameter key="trim_attribute_names" value="true"/><br> <description align="center" color="transparent" colored="false" width="126">dummy data</description><br> </operator><br> <operator activated="true" class="sort" compatibility="9.5.000" expanded="true" height="82" name="Sort" width="90" x="313" y="34"><br> <parameter key="attribute_name" value="Erstellt"/><br> <parameter key="sorting_direction" value="increasing"/><br> </operator><br> <operator activated="true" class="operator_toolbox:extract_macro_enhanced" compatibility="2.4.000-SNAPSHOT" expanded="true" height="68" name="Extract Macro (Format)" width="90" x="648" y="34"><br> <parameter key="macro" value="date"/><br> <parameter key="macro_type" value="data_value"/><br> <parameter key="statistics" value="average"/><br> <parameter key="attribute_name" value="Erstellt"/><br> <parameter key="example_index" value="1"/><br> <list key="additional_macros"/><br> <parameter key="format_of_numericals" value="#.##"/><br> <parameter key="date_format" value="dd/MM/yyyy HH:mm"/><br> <parameter key="date_type" value="date"/><br> <parameter key="time_zone" value="SYSTEM"/><br> <parameter key="locale" value="English (United States)"/><br> </operator><br> <operator activated="true" class="branch" compatibility="9.5.000" expanded="true" height="82" name="Branch" width="90" x="916" y="34"><br> <parameter key="condition_type" value="expression"/><br> <parameter key="expression" value="if(date_diff(date_parse_custom(%{date},"dd/MM/yyyy HH:mm"),date_now())>0,TRUE,FALSE)"/><br> <parameter key="io_object" value="ANOVAMatrix"/><br> <parameter key="return_inner_output" value="true"/><br> <process expanded="true"><br> <operator activated="true" class="productivity:execute_process" compatibility="9.5.000" expanded="true" height="82" name="Execute xy" width="90" x="179" y="34"><br> <parameter key="process_location" value="../../../xy"/><br> <parameter key="use_input" value="true"/><br> <parameter key="store_output" value="false"/><br> <parameter key="propagate_metadata_recursively" value="true"/><br> <parameter key="cache_process" value="true"/><br> <list key="macros"/><br> <parameter key="fail_for_unknown_macros" value="true"/><br> </operator><br> <connect from_port="condition" to_op="Execute xy" to_port="input 1"/><br> <connect from_op="Execute xy" from_port="result 1" to_port="input 1"/><br> <portSpacing port="source_condition" spacing="0"/><br> <portSpacing port="source_input 1" spacing="0"/><br> <portSpacing port="sink_input 1" spacing="0"/><br> <portSpacing port="sink_input 2" spacing="0"/><br> </process><br> <process expanded="true"><br> <operator activated="true" class="throw_exception" compatibility="9.5.000" expanded="true" height="82" name="Throw Exception" width="90" x="179" y="34"><br> <parameter key="message" value="oh no!"/><br> </operator><br> <connect from_port="condition" to_op="Throw Exception" to_port="through 1"/><br> <connect from_op="Throw Exception" from_port="through 1" to_port="input 1"/><br> <portSpacing port="source_condition" spacing="0"/><br> <portSpacing port="source_input 1" spacing="0"/><br> <portSpacing port="sink_input 1" spacing="0"/><br> <portSpacing port="sink_input 2" spacing="0"/><br> </process><br> </operator><br> <connect from_op="Create ExampleSet" from_port="output" to_op="Sort" to_port="example set input"/><br> <connect from_op="Sort" from_port="example set output" to_op="Extract Macro (Format)" to_port="example set"/><br> <connect from_op="Extract Macro (Format)" from_port="example set" to_op="Branch" to_port="condition"/><br> <connect from_op="Branch" from_port="input 1" to_port="result 1"/><br> <portSpacing port="source_input 1" spacing="0"/><br> <portSpacing port="sink_result 1" spacing="0"/><br> <portSpacing port="sink_result 2" spacing="0"/><br> </process><br> </operator><br></process><br><br>
- Sr. Director Data Solutions, Altair RapidMiner -
Dortmund, Germany5
Answers
Dortmund, Germany