fit_bagofpatterns: Fit Bag Of Patterns Histogram

View source: R/fit_bagofpatterns.R

fit_bagofpatternsR Documentation

Fit Bag Of Patterns Histogram

Description

Fit a dictionary to a dataset using SAX to create a 'bag of patterns'

Usage

fit_bagofpatterns(
  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
)

Arguments

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 sqrt(m) random windows should be taken instead of all

normalize

a logical, indicating whether each window should be z-normalized (⁠(x - mean(x)/sd(x)⁠)

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 seewave::SAX)

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.

Details

This function creates a dictionary to a dataset of time series using seewave::SAX and returns an model that can be used by bake_bagofpatterns to convert that series into a histogram of 'words'.


mattsq/bagofpatternsr documentation built on April 5, 2025, 3:05 a.m.