Loop for multiple date rows

sunnyalsunnyal Member Posts: 44 Contributor II
edited November 2018 in Help

How do we generate multiple values of a generated single attribute. I was able to generate future date of 4 rows, but what i needed is a 4 rows of different dates as depicted below.

 

Row No Date Usage
1 Jun 15 2017 0.623381
2 Jun 16 2017 0.863356
3 Jun 17 2017 0.564621
4 Jun 18 2017 0.068763

 

Attached my process

Tagged:

Answers

  • Thomas_OttThomas_Ott RapidMiner Certified Analyst, RapidMiner Certified Expert, Member Posts: 1,761 Unicorn

    There is a macro in the process called "futuerDates" (misspelled) that is set to 4. When you loop, you set the iteration to "futuerDates" so it does it only 4 times. If you want more, increase that value. 

  • Thomas_OttThomas_Ott RapidMiner Certified Analyst, RapidMiner Certified Expert, Member Posts: 1,761 Unicorn

    Oops my bad, you said you need different dates. Look at this process

     

    <?xml version="1.0" encoding="UTF-8"?><process version="7.5.001">
    <context>
    <input/>
    <output/>
    <macros>
    <macro>
    <key>horizon</key>
    <value>2</value>
    </macro>
    <macro>
    <key>symbol</key>
    <value>GPRO</value>
    </macro>
    <macro>
    <key>start_date</key>
    <value>2017-01-01</value>
    </macro>
    <macro>
    <key>end_date</key>
    <value>2017-05-01</value>
    </macro>
    <macro>
    <key>window_size</key>
    <value>1</value>
    </macro>
    </macros>
    </context>
    <operator activated="true" class="process" compatibility="6.0.002" expanded="true" name="Process">
    <parameter key="encoding" value="SYSTEM"/>
    <process expanded="true">
    <operator activated="true" class="open_file" compatibility="7.5.001" expanded="true" height="68" name="Open File" width="90" x="45" y="34">
    <parameter key="resource_type" value="URL"/>
    <parameter key="url" value="http://www.google.com/finance/historical?q=NASDAQ:%{symbol}&amp;amp;ei=Ylb_WOBdzbmZAcqZn9AG&amp;amp;output=csv"/>
    </operator>
    <operator activated="true" class="read_csv" compatibility="7.5.001" expanded="true" height="68" name="Read CSV" width="90" x="45" y="136">
    <parameter key="csv_file" value="C:\Users\THOMAS~1\AppData\Local\Temp\rm_file_2048734474644171292.dump"/>
    <parameter key="column_separators" value=","/>
    <parameter key="first_row_as_names" value="false"/>
    <list key="annotations">
    <parameter key="0" value="Name"/>
    </list>
    <list key="data_set_meta_data_information">
    <parameter key="0" value="Date.true.polynominal.attribute"/>
    <parameter key="1" value="Open.false.real.attribute"/>
    <parameter key="2" value="High.false.real.attribute"/>
    <parameter key="3" value="Low.false.real.attribute"/>
    <parameter key="4" value="Close.true.real.attribute"/>
    <parameter key="5" value="Volume.false.integer.attribute"/>
    </list>
    </operator>
    <operator activated="true" class="nominal_to_date" compatibility="7.5.001" expanded="true" height="82" name="Nominal to Date" width="90" x="179" y="34">
    <parameter key="attribute_name" value="Date"/>
    <parameter key="date_format" value="dd-MMM-yy"/>
    </operator>
    <operator activated="true" class="set_role" compatibility="7.5.001" expanded="true" height="82" name="Set Role" width="90" x="179" y="136">
    <parameter key="attribute_name" value="Date"/>
    <parameter key="target_role" value="id"/>
    <list key="set_additional_roles"/>
    </operator>
    <operator activated="false" class="rename" compatibility="7.5.001" expanded="true" height="82" name="Rename" width="90" x="45" y="289">
    <parameter key="old_name" value="%{symbol}_CLOSE"/>
    <parameter key="new_name" value="Close"/>
    <list key="rename_additional_attributes"/>
    </operator>
    <operator activated="true" class="select_attributes" compatibility="7.5.001" expanded="true" height="82" name="Select Attributes" width="90" x="179" y="238">
    <parameter key="attribute_filter_type" value="subset"/>
    <parameter key="attributes" value="Close|Date"/>
    </operator>
    <operator activated="true" class="filter_examples" compatibility="6.4.000" expanded="true" height="103" name="Filter Examples" width="90" x="179" y="340">
    <parameter key="condition_class" value="no_missing_attributes"/>
    <list key="filters_list"/>
    </operator>
    <operator activated="true" class="multiply" compatibility="7.5.001" expanded="true" height="82" name="Multiply" width="90" x="179" y="442"/>
    <operator activated="true" class="series:windowing" compatibility="7.4.000" expanded="true" height="82" name="Windowing" width="90" x="380" y="34">
    <parameter key="window_size" value="%{window_size}"/>
    <parameter key="create_label" value="true"/>
    <parameter key="label_attribute" value="Close"/>
    <parameter key="horizon" value="%{horizon}"/>
    </operator>
    <operator activated="false" class="optimize_parameters_grid" compatibility="7.5.001" expanded="true" height="124" name="Optimize Parameters (Grid)" width="90" x="514" y="187">
    <list key="parameters">
    <parameter key="SVM.kernel_gamma" value="[0.0001;1000;5;logarithmic]"/>
    <parameter key="SVM.C" value="[1;10000;5;logarithmic]"/>
    <parameter key="Validation.training_window_width" value="[4;10;3;linear]"/>
    <parameter key="Validation.test_window_width" value="[4;10;3;linear]"/>
    </list>
    <process expanded="true">
    <operator activated="true" class="series:sliding_window_validation" compatibility="7.4.000" expanded="true" height="124" name="Validation" width="90" x="112" y="34">
    <parameter key="training_window_width" value="4"/>
    <parameter key="training_window_step_size" value="1"/>
    <parameter key="test_window_width" value="4"/>
    <parameter key="horizon" value="%{horizon}"/>
    <process expanded="true">
    <portSpacing port="source_training" spacing="0"/>
    <portSpacing port="sink_model" spacing="0"/>
    <portSpacing port="sink_through 1" spacing="0"/>
    </process>
    <process expanded="true">
    <operator activated="true" class="apply_model" compatibility="7.5.001" expanded="true" height="82" name="Apply Model (2)" width="90" x="45" y="34">
    <list key="application_parameters"/>
    </operator>
    <operator activated="true" class="series:forecasting_performance" compatibility="7.4.000" expanded="true" height="82" name="Performance" width="90" x="246" y="34">
    <parameter key="horizon" value="%{horizon}"/>
    <parameter key="main_criterion" value="prediction_trend_accuracy"/>
    <parameter key="prediction_trend_accuracy" value="false"/>
    </operator>
    <connect from_port="model" to_op="Apply Model (2)" to_port="model"/>
    <connect from_port="test set" to_op="Apply Model (2)" to_port="unlabelled data"/>
    <connect from_op="Apply Model (2)" from_port="labelled data" to_op="Performance" to_port="labelled data"/>
    <connect from_op="Performance" from_port="performance" to_port="averagable 1"/>
    <portSpacing port="source_model" spacing="0"/>
    <portSpacing port="source_test set" spacing="0"/>
    <portSpacing port="source_through 1" spacing="0"/>
    <portSpacing port="sink_averagable 1" spacing="0"/>
    <portSpacing port="sink_averagable 2" spacing="0"/>
    </process>
    </operator>
    <operator activated="true" class="log" compatibility="7.5.001" expanded="true" height="82" name="Log" width="90" x="313" y="136">
    <parameter key="filename" value="tmp"/>
    <list key="log">
    <parameter key="Gamma" value="operator.SVM.parameter.kernel_gamma"/>
    <parameter key="C" value="operator.SVM.parameter.C"/>
    <parameter key="Training Width" value="operator.Validation.parameter.training_window_width"/>
    <parameter key="Testing Width" value="operator.Validation.parameter.test_window_width"/>
    <parameter key="Forecast Perf" value="operator.Validation.value.performance"/>
    </list>
    <parameter key="sorting_type" value="top-k"/>
    <parameter key="sorting_dimension" value="Forecast Perf"/>
    <parameter key="sorting_k" value="10"/>
    <parameter key="persistent" value="true"/>
    </operator>
    <connect from_port="input 1" to_op="Validation" to_port="training"/>
    <connect from_op="Validation" from_port="model" to_port="result 1"/>
    <connect from_op="Validation" from_port="averagable 1" to_op="Log" to_port="through 1"/>
    <connect from_op="Log" from_port="through 1" to_port="performance"/>
    <portSpacing port="source_input 1" spacing="0"/>
    <portSpacing port="source_input 2" spacing="0"/>
    <portSpacing port="sink_performance" spacing="0"/>
    <portSpacing port="sink_result 1" spacing="0"/>
    <portSpacing port="sink_result 2" spacing="0"/>
    </process>
    </operator>
    <operator activated="true" class="series:windowing" compatibility="7.4.000" expanded="true" height="82" name="Windowing (2)" width="90" x="380" y="136">
    <parameter key="window_size" value="%{window_size}"/>
    <parameter key="label_attribute" value="Close"/>
    </operator>
    <operator activated="true" class="extract_macro" compatibility="7.5.001" expanded="true" height="68" name="Extract Macro" width="90" x="380" y="238">
    <parameter key="macro" value="n_examples"/>
    <list key="additional_macros"/>
    </operator>
    <operator activated="true" class="generate_macro" compatibility="7.5.001" expanded="true" height="82" name="Generate Macro" width="90" x="380" y="340">
    <list key="function_descriptions">
    <parameter key="filter_range" value="eval(%{n_examples})-1"/>
    </list>
    </operator>
    <operator activated="true" class="sort" compatibility="7.5.001" expanded="true" height="82" name="Sort (2)" width="90" x="380" y="442">
    <parameter key="attribute_name" value="Date"/>
    </operator>
    <operator activated="true" class="filter_example_range" compatibility="7.5.001" expanded="true" height="82" name="Filter Example Range" width="90" x="514" y="442">
    <parameter key="first_example" value="1"/>
    <parameter key="last_example" value="%{filter_range}"/>
    <parameter key="invert_filter" value="true"/>
    </operator>
    <operator activated="true" class="remember" compatibility="7.5.001" expanded="true" height="68" name="Remember" width="90" x="648" y="442">
    <parameter key="name" value="LastRow"/>
    </operator>
    <operator activated="true" class="series:sliding_window_validation" compatibility="7.4.000" expanded="true" height="124" name="Deep Learning Window" width="90" x="514" y="34">
    <parameter key="training_window_width" value="8"/>
    <parameter key="training_window_step_size" value="1"/>
    <parameter key="test_window_width" value="8"/>
    <parameter key="horizon" value="%{horizon}"/>
    <process expanded="true">
    <operator activated="false" class="h2o:deep_learning" compatibility="7.5.000" expanded="true" height="82" name="Deep Learning" width="90" x="238" y="34">
    <enumeration key="hidden_layer_sizes">
    <parameter key="hidden_layer_sizes" value="50"/>
    <parameter key="hidden_layer_sizes" value="50"/>
    </enumeration>
    <enumeration key="hidden_dropout_ratios"/>
    <list key="expert_parameters"/>
    <list key="expert_parameters_"/>
    </operator>
    <operator activated="true" class="support_vector_machine" compatibility="7.5.001" expanded="true" height="124" name="SVM" width="90" x="246" y="136">
    <parameter key="kernel_type" value="radial"/>
    <parameter key="kernel_gamma" value="0.1"/>
    <parameter key="C" value="100.0"/>
    </operator>
    <connect from_port="training" to_op="SVM" to_port="training set"/>
    <connect from_op="SVM" from_port="model" to_port="model"/>
    <portSpacing port="source_training" spacing="0"/>
    <portSpacing port="sink_model" spacing="0"/>
    <portSpacing port="sink_through 1" spacing="0"/>
    </process>
    <process expanded="true">
    <operator activated="true" class="apply_model" compatibility="7.5.001" expanded="true" height="82" name="Apply Model (3)" width="90" x="45" y="34">
    <list key="application_parameters"/>
    </operator>
    <operator activated="true" class="series:forecasting_performance" compatibility="7.4.000" expanded="true" height="82" name="Performance (2)" width="90" x="246" y="34">
    <parameter key="horizon" value="%{horizon}"/>
    <parameter key="main_criterion" value="prediction_trend_accuracy"/>
    </operator>
    <connect from_port="model" to_op="Apply Model (3)" to_port="model"/>
    <connect from_port="test set" to_op="Apply Model (3)" to_port="unlabelled data"/>
    <connect from_op="Apply Model (3)" from_port="labelled data" to_op="Performance (2)" to_port="labelled data"/>
    <connect from_op="Performance (2)" from_port="performance" to_port="averagable 1"/>
    <portSpacing port="source_model" spacing="0"/>
    <portSpacing port="source_test set" spacing="0"/>
    <portSpacing port="source_through 1" spacing="0"/>
    <portSpacing port="sink_averagable 1" spacing="0"/>
    <portSpacing port="sink_averagable 2" spacing="0"/>
    </process>
    </operator>
    <operator activated="true" class="loop" compatibility="7.5.001" expanded="true" height="82" name="Loop" width="90" x="648" y="34">
    <parameter key="set_iteration_macro" value="true"/>
    <parameter key="macro_name" value="loop_forecasts"/>
    <parameter key="iterations" value="%{horizon}"/>
    <process expanded="true">
    <operator activated="true" class="recall" compatibility="7.5.001" expanded="true" height="68" name="Recall" width="90" x="45" y="85">
    <parameter key="name" value="LastRow"/>
    <parameter key="remove_from_store" value="false"/>
    </operator>
    <operator activated="true" class="apply_model" compatibility="7.1.001" expanded="true" height="82" name="Apply Model" width="90" x="246" y="34">
    <list key="application_parameters"/>
    </operator>
    <operator activated="true" class="generate_attributes" compatibility="7.5.001" expanded="true" height="82" name="Generate Attributes" width="90" x="380" y="34">
    <list key="function_descriptions">
    <parameter key="Date" value="date_add(Date,eval(%{loop_forecasts}),DATE_UNIT_DAY)"/>
    </list>
    </operator>
    <operator activated="true" class="set_role" compatibility="5.3.013" expanded="true" height="82" name="Set Role (2)" width="90" x="514" y="34">
    <parameter key="attribute_name" value="prediction(label)"/>
    <list key="set_additional_roles"/>
    </operator>
    <operator activated="true" class="select_attributes" compatibility="7.5.001" expanded="true" height="82" name="Select Attributes (3)" width="90" x="648" y="34">
    <parameter key="attribute_filter_type" value="single"/>
    <parameter key="attribute" value="prediction(label)"/>
    </operator>
    <operator activated="true" class="replace" compatibility="7.5.001" expanded="true" height="82" name="Replace" width="90" x="782" y="34">
    <parameter key="replace_what" value="Close"/>
    <parameter key="replace_by" value="$1-"/>
    </operator>
    <operator activated="true" class="rename" compatibility="7.5.001" expanded="true" height="82" name="Rename (2)" width="90" x="916" y="34">
    <parameter key="old_name" value="prediction(label)"/>
    <parameter key="new_name" value="Close"/>
    <list key="rename_additional_attributes"/>
    </operator>
    <operator activated="true" class="materialize_data" compatibility="7.5.001" expanded="true" height="82" name="Materialize Data (2)" width="90" x="1050" y="34"/>
    <connect from_port="input 1" to_op="Apply Model" to_port="model"/>
    <connect from_op="Recall" from_port="result" to_op="Apply Model" to_port="unlabelled data"/>
    <connect from_op="Apply Model" from_port="labelled data" to_op="Generate Attributes" to_port="example set input"/>
    <connect from_op="Generate Attributes" from_port="example set output" to_op="Set Role (2)" to_port="example set input"/>
    <connect from_op="Set Role (2)" from_port="example set output" to_op="Select Attributes (3)" to_port="example set input"/>
    <connect from_op="Select Attributes (3)" from_port="example set output" to_op="Replace" to_port="example set input"/>
    <connect from_op="Replace" from_port="example set output" to_op="Rename (2)" to_port="example set input"/>
    <connect from_op="Rename (2)" from_port="example set output" to_op="Materialize Data (2)" to_port="example set input"/>
    <connect from_op="Materialize Data (2)" 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>
    <operator activated="true" class="append" compatibility="7.5.001" expanded="true" height="82" name="Append" width="90" x="782" y="34"/>
    <operator activated="true" class="sort" compatibility="7.5.001" expanded="true" height="82" name="Sort" width="90" x="916" y="34">
    <parameter key="attribute_name" value="Date"/>
    </operator>
    <connect from_op="Open File" from_port="file" to_op="Read CSV" to_port="file"/>
    <connect from_op="Read CSV" 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="Set Role" to_port="example set input"/>
    <connect from_op="Set Role" from_port="example set output" to_op="Select Attributes" to_port="example set input"/>
    <connect from_op="Select Attributes" from_port="example set output" to_op="Filter Examples" to_port="example set input"/>
    <connect from_op="Filter Examples" from_port="example set output" to_op="Multiply" to_port="input"/>
    <connect from_op="Multiply" from_port="output 1" to_op="Windowing" to_port="example set input"/>
    <connect from_op="Windowing" from_port="example set output" to_op="Deep Learning Window" to_port="training"/>
    <connect from_op="Windowing" from_port="original" to_op="Windowing (2)" to_port="example set input"/>
    <connect from_op="Windowing (2)" 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="Sort (2)" to_port="example set input"/>
    <connect from_op="Sort (2)" from_port="example set output" to_op="Filter Example Range" to_port="example set input"/>
    <connect from_op="Filter Example Range" from_port="example set output" to_op="Remember" to_port="store"/>
    <connect from_op="Deep Learning Window" from_port="model" to_op="Loop" to_port="input 1"/>
    <connect from_op="Deep Learning Window" from_port="averagable 1" to_port="result 1"/>
    <connect from_op="Loop" from_port="output 1" to_op="Append" to_port="example set 1"/>
    <connect from_op="Append" from_port="merged set" to_op="Sort" to_port="example set input"/>
    <connect from_op="Sort" from_port="example set output" to_port="result 2"/>
    <portSpacing port="source_input 1" spacing="0"/>
    <portSpacing port="sink_result 1" spacing="0"/>
    <portSpacing port="sink_result 2" spacing="0"/>
    <portSpacing port="sink_result 3" spacing="0"/>
    </process>
    </operator>
    </process>
Sign In or Register to comment.