This function trains a model that uses a dictionary to predict state changes. Differently from fluss(), it doesn't look for semantic changes (that may be several), but for binary states like "on" or "off". Think for example that a human annotator is pressing a switch any time he thinks that the recorded data is relevant, and releases the switch when he thinks the data is noise. This algorithm will learn the switching points (even better) and try to predict using new data.

sdts_train(
  data,
  label,
  window_size,
  beta = 1,
  pat_max = Inf,
  n_workers = 1,
  verbose = getOption("tsmp.verbose", 2)
)

Arguments

data

a vector of numeric. Time series.

label

a vector of logical. Annotations.

window_size

an int or a vector of int. Sliding window sizes.

beta

a numeric. See details. (default is 1).

pat_max

an int. Max number of shape features captured. (default is Inf).

n_workers

an int. Number of workers for parallel execution. (default is 1).

verbose

an int. See details. (Default is 2).

Value

Returns a list with the learned dictionary score (estimated score), score_hist (history of scores), pattern (shape features), thold (threshold values).

Details

beta is used to balance F-score towards recall (>1) or precision (<1). verbose changes how much information is printed by this function; 0 means nothing, 1 means text, 2 adds the progress bar.

References

  • Yeh C-CM, Kavantzas N, Keogh E. Matrix profile IV: Using Weakly Labeled Time Series to Predict Outcomes. Proc VLDB Endow. 2017 Aug 1;10(12):1802-12.

Website: https://sites.google.com/view/weaklylabeled

See also

Other Scalable Dictionaries: sdts_predict(), sdts_score()

Examples

# This is a fast toy example and results are useless. For a complete result, run the code inside
#' Not run' section below.
w <- c(110, 220)
subs <- 11000:20000
tr_data <- mp_test_data$train$data[subs]
tr_label <- mp_test_data$train$label[subs]
te_data <- mp_test_data$test$data[subs]
te_label <- mp_test_data$test$label[subs]
model <- sdts_train(tr_data, tr_label, w, verbose = 0)
predict <- sdts_predict(model, te_data, round(mean(w)))
sdts_score(predict, te_label, 1)
# \donttest{
windows <- c(110, 220, 330)
model <- sdts_train(mp_test_data$train$data, mp_test_data$train$label, windows)
#> Stage 1 of 3, compute matrix profile...
#> 
Computing: [====                                    ] 8%  (~12s remaining)       
Computing: [======                                  ] 15%  (~11s remaining)       
Computing: [=========                               ] 22%  (~11s remaining)       
Computing: [============                            ] 28%  (~10s remaining)       
Computing: [==============                          ] 35%  (~9s remaining)       
Computing: [=================                       ] 42%  (~8s remaining)       
Computing: [====================                    ] 49%  (~7s remaining)       
Computing: [======================                  ] 55%  (~6s remaining)       
Computing: [=========================               ] 62%  (~5s remaining)       
Computing: [============================            ] 69%  (~4s remaining)       
Computing: [==============================          ] 75%  (~3s remaining)       
Computing: [=================================       ] 82%  (~2s remaining)       
Computing: [====================================    ] 89%  (~1s remaining)       
Computing: [======================================= ] 96%  (~0s remaining)       
Computing: [========================================] 100% (done)                         
#> 
Computing: [====                                    ] 9%  (~11s remaining)       
Computing: [=======                                 ] 16%  (~11s remaining)       
Computing: [==========                              ] 23%  (~10s remaining)       
Computing: [============                            ] 30%  (~9s remaining)       
Computing: [===============                         ] 37%  (~8s remaining)       
Computing: [==================                      ] 45%  (~7s remaining)       
Computing: [=====================                   ] 52%  (~6s remaining)       
Computing: [========================                ] 59%  (~5s remaining)       
Computing: [===========================             ] 66%  (~4s remaining)       
Computing: [==============================          ] 73%  (~3s remaining)       
Computing: [=================================       ] 81%  (~2s remaining)       
Computing: [====================================    ] 88%  (~1s remaining)       
Computing: [======================================  ] 95%  (~0s remaining)       
Computing: [========================================] 100% (done)                         
#> 
Computing: [====                                    ] 9%  (~11s remaining)       
Computing: [=======                                 ] 16%  (~10s remaining)       
Computing: [==========                              ] 23%  (~10s remaining)       
Computing: [============                            ] 30%  (~9s remaining)       
Computing: [================                        ] 38%  (~8s remaining)       
Computing: [==================                      ] 44%  (~7s remaining)       
Computing: [=====================                   ] 51%  (~6s remaining)       
Computing: [========================                ] 59%  (~5s remaining)       
Computing: [===========================             ] 66%  (~4s remaining)       
Computing: [==============================          ] 73%  (~3s remaining)       
Computing: [================================        ] 80%  (~2s remaining)       
Computing: [====================================    ] 88%  (~1s remaining)       
Computing: [======================================  ] 95%  (~0s remaining)       
Computing: [========================================] 100% (done)                         
#> Stage 2 of 3, evaluate individual candidates...
#> Finished in 15.80 secs
#> Stage 3 of 3, evaluate combination of candidates...
#> Finished in 9.57 mins
predict <- sdts_predict(model, mp_test_data$test$data, round(mean(windows)))
sdts_score(predict, mp_test_data$test$label, 1)
# }