Skip to content

Commit 32f139b

Browse files
authored
Merge pull request #15 from muazhari/master
Update regression_forecast method and bug fix
2 parents 830f58c + 3bd20c4 commit 32f139b

3 files changed

Lines changed: 1287 additions & 1206 deletions

File tree

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,28 @@ Based on the value of the first 10 datapoints of the sin wave, out forecast indi
319319

320320
As we can see on the chart, the 11th datapoint's value seems to be around 92, as was forecasted.
321321

322+
We can also use `regression_forecast` method, which will using regression to forecast n datapoints based on defined sample from dataset. For resulting forecast datapoint same as above, we will first define the options:
323+
```
324+
var options = {
325+
n: 1, // How many data points to be forecasted
326+
sample: 10, // How many datapoints to be training dataset
327+
start: 11, // Initial forecasting position
328+
// method: "ARMaxEntropy", // What method for forecasting
329+
// degree: 5, // How many degree for forecasting
330+
// growthSampleMode: false, // Is the sample use only last x data points or up to entire data points?
331+
}
332+
```
333+
334+
Now, we generate the regression forecast on the data, then it resulted the MSE & trained data:
335+
```
336+
var MSE = t.regression_forecast(options)
337+
338+
console.log(MSE) // 0.000022902164211893183
339+
console.log(t.data[10][1]) // 93.97404769915791
340+
```
341+
342+
Based on the value of the first 10 datapoints of the sin wave, out forecast indicates the 11th value is 93.97404769915791. This interesting because the 11th observed real datapoint value is 93.96926207859084, which means it seems as was forecasted.
343+
322344

323345
#### Forecast accuracy ####
324346
In order to check the forecast accuracy on more complex data, you can access the `sliding_regression_forecast` method, which will use a sliding window to forecast all of the datapoints in your dataset, one by one. You can then chart this forecast and compare it t the original data.

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
},
77
"name": "timeseries-analysis",
88
"description": "timeseries-analysis",
9-
"version": "1.0.11",
9+
"version": "1.0.12",
1010
"homepage": "https://github.com/26medias/timeseries-analysis",
1111
"licenses": [
12-
{
13-
"type": "MIT",
14-
"url": "https://raw.github.com/26medias/timeseries-analysis/master/LICENSE"
15-
}
12+
{
13+
"type": "MIT",
14+
"url": "https://raw.github.com/26medias/timeseries-analysis/master/LICENSE"
15+
}
1616
],
1717
"repository": {
1818
"type": "git",
@@ -31,6 +31,6 @@
3131
"bugs": {
3232
"url": "https://github.com/26medias/timeseries-analysis/issues"
3333
},
34-
"_id": "timeseries-analysis@1.0.11",
34+
"_id": "timeseries-analysis@1.0.12",
3535
"_from": "timeseries-analysis@latest"
36-
}
36+
}

0 commit comments

Comments
 (0)