A library for automated time series prediction
Statistical forecasting with automated model selection and hyperparameter optimization - One-line ARIMA selection and fitting with both stochastic and deterministic training options (meant as an alternative to auto.arima) - One-line Box-Jenkins model constuction with training options for approximation metaheuristic
Manual time series analysis - Backwards compatibility with package 'forecast' (for Hyndman's ARIMA, neural network autoregression, and exponential smoothing) - In-sample and out-of-sample model validation (diagnose overfitting/underfitting via train-test splitting)
AutoML for univariate series - Train multiple weak learners to make stronger predictions (ensemble learning / stacking) - Train all models in 'karma' and 'forecast' on a single time series dataset - Train all models in 'karma' and 'forecast' on multiple time series datasets and benchmark their results
Model selection algorithms
Instructions
You first install these packages:
install.packages(c('devtools', 'forecast', 'stringr'))
Then you load devtools:
library(devtools)
Then you install this package:
install_github("snarf-snarf/karma")
Then you load all packages:
library(karma)
library(forecast)
library(stringr)
Examples:
Search for optimal SARIMA model using auto.karma with cross-validation:
sfit <- auto.karma( mdeaths ) # train SARIMA/ARIMA model
Retrain selected model (training set) and validate prediction accuracy on held out data (test set):
karma.cv( sfit ) # will plot predicted vs. actual test-set data and print out test MAPE
Forecast future periods:
plot(forecast( sfit )) # plot projection
Use karma API with 'forecast' package:
afit <- auto.arima(mdeaths) # auto.arima
karma.cv( afit )
plot(forecast( afit ))
nfit <- nnetar(mdeaths) # shallow neural network autoregression
karma.cv( nfit )
plot(forecast( nfit ))
efit <- ets(mdeaths) # exponential smoothing state space model
karma.cv( efit )
plot(forecast( efit ))
# ...etc...
Train multiple models on a single series:
kmodels <- magic.karma(mdeaths) # train all models
karma.cv(kmodels[[1]]$fit_obj) # validate 1st model
karma.cv(kmodels[[2]]$fit_obj) # validate 2nd model
# ...etc...
Or you can follow the examples on this script:
https://github.com/snarf-snarf/karma/blob/master/karma_demo.r
Use help() on any function to see a more detailed documentation.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.