how to do 30 days forecast
boza
New Altair Community Member
Attributes which I use (i-th day):
...
day i: att1 att2 att3(day i-1) att4(day i-2) att5(day i-3) att6(day i-4) att7(day i-5) label:att8(day i)
...
I make example set and generate model. This is not a problem, but if I want to do prediction for 30 days ahead, my test set must include previous predicted values:
day 1: x1 y1 a1 b1 c1 d1 e1 f1-prediction
day 2: x2 y2 f1 a1 b1 c1 d1 f2
day 3: x3 y3 f2 f1 a1 b1 c1 f3
....
day 30: x30 y30 f29 f28 f27 f26 f25 f30.
I want to do prediction for 30 day ahead at once, and how I can do that if possible?
...
day i: att1 att2 att3(day i-1) att4(day i-2) att5(day i-3) att6(day i-4) att7(day i-5) label:att8(day i)
...
I make example set and generate model. This is not a problem, but if I want to do prediction for 30 days ahead, my test set must include previous predicted values:
day 1: x1 y1 a1 b1 c1 d1 e1 f1-prediction
day 2: x2 y2 f1 a1 b1 c1 d1 f2
day 3: x3 y3 f2 f1 a1 b1 c1 f3
....
day 30: x30 y30 f29 f28 f27 f26 f25 f30.
I want to do prediction for 30 day ahead at once, and how I can do that if possible?
Tagged:
0
Answers
-
Hi,
usually you are using a horizon of 30 days during the windowing if you are going to predict whats going on 30 days ahead.
Greetings,
Sebastian0 -
Thank you Sebastian for answer but I think I wasn't clear enough.
I have test set like this for predict one day ahead:
1: 11.1 2.2 267460 274321 277649 278393 269084 f1-prediction
and if I apply model, RM give me f1 and that is ok.
But for example if I want to predict two days ahead, my test set is:
1: 11.1 2.2 267460 274321 277649 278393 269084 f1
2: 6.7 4 f1 215147 267460 274321 277649 f2
you see that I need the predicted value from day before to use for prediction of next day.
I can do this manual but that isn't efficiently.
One more thing is that the first and second attribute aren't time-series data unlike attributes from 3 to 5 which are time-series data.
Sebastian said to use windowing operator but I think that won't help in this problem, or maybe I don't understand windowing operator.
0 -
I have same problem, I want to use predicted value from i-th iteration as input for i+1 iteration. (problem of load forecasting).
I use LibSVM (Suport Vector Regression) for load forecasting. I want to put predicted value for Monday into input vector for Tuesday (to use predicted values for 7 days before for predicting next day, so I need to add predicted values into input vectors for next day). Can this be done automatically in some kind of loop ? Otherwise I must manually to to shift vector for one position in left and copy predicted value for day before into input vector. All this must be done in test phase (during execution of LibSVM).0 -
Hi,
unfortunately there's currently no operator supporting this directly, at least as far as I know. I would ask one of our experts for time series prediction, but both are currently working at a customer's site.
I think the only way you can handle this problem is renaming the attribute after each application and using the prediction for as last time point for applying the model again.
I tried to model this in a process, that performs this automatically, but unfortunately I'm lacking the time to debug it. Perhaps it helps you anyway, so I will post it here:<?xml version="1.0" encoding="UTF-8" standalone="no"?>
There's another, possibly better way around, but I can only sketch it up here:
<process version="5.0">
<context>
<input/>
<output/>
<macros/>
</context>
<operator activated="true" class="process" expanded="true" name="Process">
<process expanded="true" height="449" width="882">
<operator activated="true" class="generate_data" expanded="true" height="60" name="Generate Data" width="90" x="45" y="30">
<parameter key="number_examples" value="1000"/>
<parameter key="number_of_attributes" value="1"/>
</operator>
<operator activated="true" class="series:windowing" expanded="true" height="76" name="Windowing" width="90" x="179" y="30">
<parameter key="window_size" value="10"/>
</operator>
<operator activated="true" class="set_role" expanded="true" height="76" name="Set Role" width="90" x="313" y="30">
<parameter key="name" value="att1-0"/>
<parameter key="target_role" value="label"/>
</operator>
<operator activated="true" class="linear_regression" expanded="true" height="76" name="Linear Regression" width="90" x="447" y="30"/>
<operator activated="true" class="select_attributes" expanded="true" height="76" name="remove label" width="90" x="447" y="210">
<parameter key="attribute_filter_type" value="single"/>
<parameter key="attribute" value="att1-0"/>
<parameter key="invert_selection" value="true"/>
<parameter key="include_special_attributes" value="true"/>
</operator>
<operator activated="true" class="remember" expanded="true" height="60" name="Remember" width="90" x="581" y="210">
<parameter key="name" value="es"/>
<parameter key="io_object" value="ExampleSet"/>
</operator>
<operator activated="true" class="loop" expanded="true" height="76" name="Loop" width="90" x="715" y="30">
<parameter key="iterations" value="30"/>
<process expanded="true" height="460" width="1016">
<operator activated="true" class="recall" expanded="true" height="60" name="Recall" width="90" x="45" y="75">
<parameter key="name" value="es"/>
<parameter key="io_object" value="ExampleSet"/>
</operator>
<operator activated="true" class="apply_model" expanded="true" height="76" name="Apply Model" width="90" x="246" y="30">
<list key="application_parameters"/>
</operator>
<operator activated="true" breakpoints="after" class="loop_attributes" expanded="true" height="60" name="Loop Attributes" width="90" x="380" y="30">
<parameter key="iteration_macro" value="currentAttribute"/>
<process expanded="true" height="460" width="966">
<operator activated="true" class="branch" expanded="true" height="76" name="Branch" width="90" x="112" y="30">
<parameter key="condition_type" value="macro_defined"/>
<parameter key="condition_value" value="lastAttribute"/>
<process expanded="true" height="460" width="480">
<operator activated="true" class="select_attributes" expanded="true" height="76" name="Select Attributes" width="90" x="45" y="30">
<parameter key="attribute_filter_type" value="regular_expression"/>
<parameter key="regular_expression" value="%{lastAttribute}"/>
<parameter key="invert_selection" value="true"/>
</operator>
<operator activated="true" class="rename" expanded="true" height="76" name="Rename" width="90" x="179" y="30">
<parameter key="old_name" value="%{currentAttribute}"/>
<parameter key="new_name" value="%{lastAttribute}"/>
</operator>
<operator activated="true" class="provide_macro_as_log_value" expanded="true" height="76" name="currentAttribute" width="90" x="45" y="165">
<parameter key="macro_name" value="currentAttribute"/>
</operator>
<operator activated="true" class="provide_macro_as_log_value" expanded="true" height="76" name="lastAttribute" width="90" x="179" y="165">
<parameter key="macro_name" value="lastAttribute"/>
</operator>
<operator activated="true" class="log" expanded="true" height="76" name="Log" width="90" x="179" y="300">
<list key="log">
<parameter key="current" value="operator.currentAttribute.value.macro_value"/>
<parameter key="last" value="operator.lastAttribute.value.macro_value"/>
<parameter key="round" value="operator.Loop Attributes.value.applycount"/>
</list>
</operator>
<operator activated="true" class="set_macro" expanded="true" height="76" name="Set Macro" width="90" x="313" y="300">
<parameter key="macro" value="lastAttribute"/>
<parameter key="value" value="%{currentAttribute}"/>
</operator>
<connect from_port="condition" to_op="Select Attributes" to_port="example set input"/>
<connect from_op="Select Attributes" from_port="example set output" to_op="Rename" to_port="example set input"/>
<connect from_op="Rename" from_port="example set output" to_op="currentAttribute" to_port="through 1"/>
<connect from_op="currentAttribute" from_port="through 1" to_op="lastAttribute" to_port="through 1"/>
<connect from_op="lastAttribute" from_port="through 1" to_op="Log" to_port="through 1"/>
<connect from_op="Log" from_port="through 1" to_op="Set Macro" to_port="through 1"/>
<connect from_op="Set Macro" 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>
<process expanded="true" height="460" width="458">
<operator activated="true" class="set_macro" expanded="true" height="76" name="Set Macro (2)" width="90" x="313" y="30">
<parameter key="macro" value="lastAttribute"/>
<parameter key="value" value="%{currentAttribute}"/>
</operator>
<connect from_port="condition" to_op="Set Macro (2)" to_port="through 1"/>
<connect from_op="Set Macro (2)" 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_port="example set" to_op="Branch" to_port="condition"/>
<connect from_op="Branch" from_port="input 1" to_port="example set"/>
<portSpacing port="source_example set" spacing="0"/>
<portSpacing port="sink_example set" spacing="0"/>
</process>
</operator>
<operator activated="true" class="set_role" expanded="true" height="76" name="Set Role (2)" width="90" x="514" y="30">
<parameter key="name" value="prediction(att1-0)"/>
</operator>
<operator activated="true" breakpoints="after" class="rename" expanded="true" height="76" name="Rename (2)" width="90" x="648" y="30">
<parameter key="old_name" value="prediction(att1-0)"/>
<parameter key="new_name" value="att1-1"/>
</operator>
<operator activated="true" class="remember" expanded="true" height="60" name="Remember (2)" width="90" x="782" y="75">
<parameter key="name" value="es"/>
<parameter key="io_object" value="ExampleSet"/>
</operator>
<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="Loop Attributes" to_port="example set"/>
<connect from_op="Loop Attributes" from_port="example set" to_op="Set Role (2)" to_port="example set input"/>
<connect from_op="Set Role (2)" 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="Remember (2)" to_port="store"/>
<portSpacing port="source_input 1" spacing="0"/>
<portSpacing port="source_input 2" spacing="162"/>
<portSpacing port="sink_output 1" spacing="0"/>
<portSpacing port="sink_output 2" spacing="0"/>
</process>
</operator>
<connect from_op="Generate Data" from_port="output" to_op="Windowing" to_port="example set input"/>
<connect from_op="Windowing" 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="Linear Regression" to_port="training set"/>
<connect from_op="Linear Regression" from_port="model" to_op="Loop" to_port="input 1"/>
<connect from_op="Linear Regression" from_port="exampleSet" to_op="remove label" to_port="example set input"/>
<connect from_op="remove label" from_port="example set output" to_op="Remember" to_port="store"/>
<connect from_op="Loop" 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>
Write a translation in the form old name, new name for each attribute manually. Load it as an example set and iterate over this example set using the Example iterator. Retrieve the data from the current example using the extract macro operator and use this two value for renaming the attributes.
My process fails because the order of the attributes changes intermediate, so that attributes are renamed to wrong names. The above solution would avoid this.
Greetings,
Sebastian0 -
Thank you Sebastian, if you remember any other easier or automatic solution please inform us.0