
Fit classifiers using time-series features using a resample-based approach and get a fast understanding of performance
Source:R/classify.R
classify.RdFit classifiers using time-series features using a resample-based approach and get a fast understanding of performance
Usage
classify(
data,
classifier = NULL,
train_size = 0.75,
n_resamples = 30,
by_set = TRUE,
use_null = FALSE,
seed = 123
)
tsfeature_classifier(
data,
classifier = NULL,
train_size = 0.75,
n_resamples = 30,
by_set = TRUE,
use_null = FALSE,
seed = 123
)Arguments
- data
feature_calculationsobject containing the raw feature matrix produced bytheft::calculate_features- classifier
functionspecifying the classifier to fit. Should be a function with 2 arguments:formulaanddatacontaining a classifier compatible with R'spredictfunctionality. Please note thatclassifyz-scores data prior to modelling using the train set's information so disabling default scaling if your function uses it is recommended. Defaults toNULLwhich means the following linear SVM is fit:classifier = function(formula, data){mod <- e1071::svm(formula, data = data, kernel = "linear", scale = FALSE, probability = TRUE)}- train_size
numericdenoting the proportion of samples to use in the training set. Defaults to0.75- n_resamples
integerdenoting the number of resamples to calculate. Defaults to30- by_set
Booleanspecifying whether to compute classifiers for each feature set. Defaults toTRUE. IfFALSE, the function will instead find the best individually-performing features- use_null
Booleanwhether to fit null models where class labels are shuffled in order to generate a null distribution that can be compared to performance on correct class labels. Defaults toFALSE- seed
integerto fix R's random number generator to ensure reproducibility. Defaults to123
Value
list containing a named vector of train-test set sizes, and a data.frame of classification performance results
Examples
library(theft)
features <- theft::calculate_features(theft::simData,
feature_set = "catch22")
#> Running computations for catch22...
#> Warning: There was 1 warning in `dplyr::reframe()`.
#> ℹ In argument: `Rcatch22::catch22_all(values, catch24 = catch24)`.
#> ℹ In group 1: `id = "AR(1)_1"` `process = "AR(1)"`.
#> Caused by warning:
#> ! As of 0.1.14 the feature 'CO_f1ecac' returns a double instead of int
#> This warning is displayed once per session.
classifiers <- classify(features,
by_set = FALSE,
n_resamples = 3)
#> Only one set of 'catch22', 'feasts', 'tsfeatures', or 'Kats' with potential duplicates is in your feature data. Exiting and returning original input data.
#> Generating resampled data...
#> Fitting model 1/66
#> Fitting model 2/66
#> Fitting model 3/66
#> Fitting model 4/66
#> Fitting model 5/66
#> Fitting model 6/66
#> Fitting model 7/66
#> Fitting model 8/66
#> Fitting model 9/66
#> Fitting model 10/66
#> Fitting model 11/66
#> Fitting model 12/66
#> Fitting model 13/66
#> Fitting model 14/66
#> Fitting model 15/66
#> Fitting model 16/66
#> Fitting model 17/66
#> Fitting model 18/66
#> Fitting model 19/66
#> Fitting model 20/66
#> Fitting model 21/66
#> Fitting model 22/66
#> Fitting model 23/66
#> Fitting model 24/66
#> Fitting model 25/66
#> Fitting model 26/66
#> Fitting model 27/66
#> Fitting model 28/66
#> Fitting model 29/66
#> Fitting model 30/66
#> Fitting model 31/66
#> Fitting model 32/66
#> Fitting model 33/66
#> Fitting model 34/66
#> Fitting model 35/66
#> Fitting model 36/66
#> Fitting model 37/66
#> Fitting model 38/66
#> Fitting model 39/66
#> Fitting model 40/66
#> Fitting model 41/66
#> Fitting model 42/66
#> Fitting model 43/66
#> Fitting model 44/66
#> Fitting model 45/66
#> Fitting model 46/66
#> Fitting model 47/66
#> Fitting model 48/66
#> Fitting model 49/66
#> Fitting model 50/66
#> Fitting model 51/66
#> Fitting model 52/66
#> Fitting model 53/66
#> Fitting model 54/66
#> Fitting model 55/66
#> Fitting model 56/66
#> Fitting model 57/66
#> Fitting model 58/66
#> Fitting model 59/66
#> Fitting model 60/66
#> Fitting model 61/66
#> Fitting model 62/66
#> Fitting model 63/66
#> Fitting model 64/66
#> Fitting model 65/66
#> Fitting model 66/66