A unified, fexible and interpretable representation learning framework for univariate and multivariate time-series (MTS)
import numpy as np
import pandas as pd
from os import listdir
from RandTS import *
directory = r'Dataset_Univariate\\'
datasets = listdir(directory)
train,test,labels_train,labels_test,X_train,X_test = load_data_new(directory, datasets[0])
classifier = RandTS()
classifier.fit(X_train,labels_train)
y_pred = classifier.predict(X_test,labels_test)
classifier.test_accuracy
>>> 0.7714285714285715
RandTS(method = 'l',depth = 5, ntree=10, var=10, featureSelection = None)
RandTS object with specified paramters:
- method = {'l','d','b'} : 'l' for 'level', 'd' for 'difference', 'b' for both
- depth (int) : Tree depth
- ntree (int) : Number of randomized trees
- featureSelection: {None, 'supervised', 'unsupervised'}
- var (int) : Works with unsupervised feature selection. Sepcifies variance threshold for elimination
RandTS.fit(train, train_labels)
Trains the RandTS model on the given data. It does not directly use train_labels but it stores it in order to make prediction in the following steps.
RandTS.predict(test, test_labels)
Predicts the test lables based on the provided test data and returns the predictions.
RandTS.selectParameters(train, train_labels, param_kwargs={'depth_cv':[3,5,10], 'ntree_cv':[100], 'rep_num':1, 'method_cv':['l','d','b']})
Applies parameter selection in a given set of parameters and replication number.
param_kwargs (dict): parameter set that is considered in parameter selection.
- 'depth_cv':[3,5,10]
- 'ntree_cv':[100]
- 'rep_num':1
- 'method_cv':['l','d','b']
RandTSMultivariate(method = 'l',depth = 5, ntree=10, var=10, featureSelection = None)
RandTS object with specified paramters:
- method = {'l','d','b'} : 'l' for 'level', 'd' for 'difference', 'b' for both
- depth (int) : Tree depth
- ntree (int) : Number of randomized trees
- featureSelection: {None, 'supervised', 'unsupervised'}
- var (int) : Works with unsupervised feature selection. Sepcifies variance threshold for elimination
RandTSMultivariate.fit(train, train_labels, ndims)
Trains the RandTS model on the given data. It does not directly use train_labels but it stores it in order to make prediction in the following steps.
- ndims: Number of variables in the multivariate time series.
RandTSMultivariate.predict(test, test_labels)
Predicts the test lables based on the provided test data and returns the predictions.
RandTS.selectParameters(train, train_labels, param_kwargs={'depth_cv':[3,5,10], 'ntree_cv':[100], 'rep_num':1, 'method_cv':['l','d','b']})
Applies parameter selection in a given set of parameters and replication number.
param_kwargs (dict): parameter set that is considered in parameter selection.
- 'depth_cv':[3,5,10]
- 'ntree_cv':[100]
- 'rep_num':1
- 'method_cv':['l','d','b']
If you use Rand-TS in a scientific publication, we would appreciate citations to the following paper:
Berk Gorgulu, Mustafa Gokce Baydogan (2021): “Randomized Trees for Time Series Representation and Similarity”
Bibtex entry:
@article{gorgulu2021randomized,
title={Randomized Trees for Time Series Representation and Similarity},
author={G{\"o}rg{\"u}l{\"u}, Berk and Baydo{\u{g}}an, Mustafa G{\"o}k{\c{c}}e},
journal={Pattern Recognition},
pages={108097},
year={2021},
publisher={Elsevier}
}