View source: R/bag_of_patterns_knn.R
bagofpatterns_knn | R Documentation |
Fit a Bag of Patterns Model with KNN
bagofpatterns_knn(
data,
target = "target",
window_size = 0.2,
sparse_windows = FALSE,
normalize = FALSE,
alphabet_size = 4,
word_size = 8,
breakpoints = "quantiles",
word_weighting = tm::weightTf,
maximum_sparsity = NA,
verbose = TRUE,
k = 3,
algorithm = "kd_tree",
prob = FALSE
)
data |
a data frame where each row is a time series, along with a column for class |
target |
the name of the column where the class of each row is stored |
window_size |
The size of the sliding windows as applied to the time series, either as a fraction of the length or an integer of precise length. |
sparse_windows |
a logical, indicating whether |
normalize |
a logical, indicating whether each window should be z-normalized ( |
alphabet_size |
the number of distinct letters to use in the compressed SAX representation |
word_size |
the size of the 'words' generated out of the alphabet by SAX |
breakpoints |
the method used to assign letters (see |
word_weighting |
The weighting function for the DTM/TDM (default is term-frequency, effectively unweighted) |
maximum_sparsity |
A optional numeric for the maximal allowed sparsity in the range from bigger zero to smaller one. |
verbose |
whether to print the progress of model creation. |
... |
arguments to be passed to |
This function fits a bag of patterns model by using Symbolic Aggregate eXpressions (SAX) to convert a data frame of time series into a count table of 'words' as generated by SAX generated by sliding windows over the series. New examples are then fit by finding nearest neighbor examples with the converted training data.
data("FaceAll_TRAIN")
model <- bagofpatterns_knn(FaceAll_TRAIN, window_size = .9, alphabet_size = 2, word_size = 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.