This R package provides tools for machine-learning based time-series prediction. This includes preprocessing, creating matrices of lags, building a pipeline, and specialized cross-validation.
You can install the latest version from Github:
if (!require("devtools")) install.packages("devtools")
devtools::install_github("fnoorian/mltsp")
This package includes two vignettes:
To build a non-linear auto-regressive model for
lh
(Luteinizing Hormone in Blood Samples, datasets
package) with
d = 0
,p = 3
,freq = 1
,D =0
,P = 0
,svm
learner from package e1071,use:
library("mltsp")
library("e1071")
spec = build_narx(svm, p = 3, d = 0, P = 0, D = 0, freq = 1)
model = narx(spec, lh, xreg = NULL)
These steps can be combined into one (and default values can used):
model = narx(lh, svm, p = 3)
To predict 5 steps ahead, simply use:
forecast(model, h = 5)
Output is compatible with package forecast.
To build a pipeline for predicting
lh
(Luteinizing Hormone in Blood Samples from datasets
package) with
use:
library("mltsp")
pp <- list(list("diff", "auto"))
fx <- function(x) cbind(x, lag_windows(x, p = 3))
ln <- SimpleLM
fcster <- mltsp_forecaster(pp, fx, ln)
and then apply function fcster
to data:
fcster(lh, h = 5)
To get cross-validation score for fcster
function for a horizon of 5 steps,
with training on at least 10 data points, use:
ts_crossval(lh, fcster, horizon = 5, initial_window = 10)
Copyright 2016 Farzad Noorian farzad.noorian@gmail.com, Richard Davis davisconsulting@gmail.com, Anthony Mihirana de Silva mihids@gmail.com, Lei Li leili8878@gmail.com.
Some functionality have been taken from GPL package caret.
For a list of other functions dynamically imported from other R packages, see NAMESPACE
file.
This package is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version.
This package is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this package. If not, see http://www.gnu.org/licenses/.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.