A large number of time-series classifiers have been implemented in Java for the benchmark study The Great Time Series Classification Bake Off (Bagnall et al., 2018). Paper
The R-package tsclassification interfaces an adapted version of implementations provided by Bagnall et al. (2018), in order to make implemented algorithms available for general machine learning purposes.
The package can be installed from Github via
devtools::install_github("compstat-lmu/tsclassification")
See the Troubleshooting section of this README for more info if the installation fails.
Note that our package name is in lowercase letters.
library(tsclassification)
We showcase the usage for a simulated data set.
First we generate some artificial data:
data = data.frame(matrix(rnorm(500), nrow = 100))
data$target = sample(c(1, 0), 100, replace = TRUE)
train_set = sample(c(TRUE, FALSE), 100, replace = TRUE)
Training a model:
Then we train a RotationForest
model.
The API is similar to python's scikit-learn
API.
It offers a train()
method, that trains a model, and a predict()
method that uses the trained
model in order to predict future, unseen data.
# Instantiate the model
tsc = TSClassifier$new("weka.classifiers.meta.RotationForest")
# Call train and predict function on the different data splits
tsc$train(data[train_set, ],target = "target")
tsc$predict(data[!train_set, ])
For a more in-depth example, please consult the vignette.
The package offers also offers connector to the machine learning toolbox mlr3
.
Learners contained in the package can directly be used in conjunction
with the powerful functionalities of mlr3
like resampling, tuning and so on.
An example of doing this for the popular iris dataset (considering the features as "functional") is shown below:
library(mlr3)
tsk = mlr_tasks$get("iris")
lrn = LearnerClassifTSClassification$new()
# Train the classifier
lrn$train(tsk)
# Predict
prds = lrn$predict(tsk)
For a more in-depth introduction to mlr3
, please consult the
mlr3 book.
Additionally, the vignette.
contains an example for tuning a time-series classifier.
The package currently supports most of the algorithms implemented in the Bake-Off.
Time Domain Distance Based Classifiers
Differential Distance Based Classifiers
Dictionary Based Classifiers
Shapelet Based Classifiers
Interval Based Classifiers
Ensemble Classifiers
On some systems, installing rJava
does not work out of the box.
Various topics regarding this are available on stackoverflow.
On unix based systems, a simple fix that often works is to run sudo R CMD javareconf
in the command line before restarting R and installing again.
Unfortunately our software requires a java binary. This binary has around 40 MB, which is to big for CRAN packages.
We appreciate bug-reports and contributions! Feel free to contact us if any questions arise!
Contributions and new ideas are welcome, feel free to open an issue or pull request on GitHub. It is advised to contact the Authors before (via Email or an Issue) in order to avoid duplicate work.
If you encounter errors with the software or require assistance, contact us on GitHub.
The code for the .jar
file underlying TSClassification
can be obtained from the jTSC4R repository. We aim to track changes made by the authors of the TimeSeries Classification Bakeoff there.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.