Nothing
library(segen)
set.seed(19)
x <- data.frame(a = rnorm(100), b = rnorm(100))
run <- function(x, ...) segen(x, seq_len = 6, similarity = 0.6,
n_windows = 2, n_samp = 2, seed = 11, ...)
for (method in c('euclidean', 'manhattan', 'maximum', 'minkowski', 'correlation', 'dtw')) {
fit <- run(x, dist_method = method)
stopifnot(length(fit$best_model$predictions) == 2L,
inherits(fit$best_model$plots[[1]], 'segen_plot'))
}
seq_fit <- run(x)
par_fit <- run(x, use_parallel = TRUE, parallel_workers = 2)
stopifnot(identical(seq_fit$history, par_fit$history),
identical(seq_fit$best_model$predictions, par_fit$best_model$predictions))
x$a[c(1, 20, 100)] <- NA
stopifnot(nrow(run(x, smoother = TRUE)$history) == 2L)
cat_fit <- run(data.frame(a = rep(c('a', 'b', NA, 'c'), 25)))
stopifnot(length(cat_fit$best_model$predictions) == 2L)
constant <- run(data.frame(a = rep(1, 100)))
stopifnot(all(is.finite(constant$best_model$predictions[[1]][, '50%'])))
X <- matrix(c(0,1,2,2,1,0), nrow=2, byrow=TRUE)
for (method in c('euclidean','manhattan','maximum','minkowski')) {
stopifnot(isTRUE(all.equal(segen:::compute_distance(X,method),
as.matrix(stats::dist(X,method=method,p=3)))))
}
stopifnot(segen:::compute_dtw_distance(matrix(c(0,1,0,2),2,byrow=TRUE))[1,2] == 2,
abs(segen:::entropy(c(0,1)) - log(2)) < 1e-12,
identical(segen:::impute_numeric(c(NA,1,NA,3,NA)), c(1,1,2,3,3)))
pdf_file <- tempfile(fileext = '.pdf')
grDevices::pdf(pdf_file)
plot(seq_fit$best_model$plots[[1]])
grDevices::dev.off()
stopifnot(file.info(pdf_file)$size > 0)
unlink(pdf_file)
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.