knitr::opts_chunk$set(collapse = TRUE, comment = "#>", fig.width = 7, fig.height = 4) library(segen)
segen forecasts numeric or categorical sequences by comparing recent
windows with historical windows and aggregating similar sequences.
The package includes a small example dataset. The following deliberately uses one validation window and one sampled model so that the vignette runs quickly.
set.seed(123) fit <- segen( time_features[, "IBM.Close", drop = FALSE], seq_len = 12, similarity = 0.7, n_windows = 2, n_samp = 1, seed = 123 ) head(fit$history) fit$best_model$predictions$IBM.Close
The result contains the model search history, the selected model's predictions and testing errors, plots, and elapsed-time information.
fit$best_model$plots$IBM.Close
Set seed whenever results need to be reproduced. This controls model
sampling and uncertainty draws. segen runs sequentially by default.
All six distance methods, including DTW with the symmetric2 recurrence, are implemented using standard R libraries. Parallel execution uses PSOCK workers from the standard parallel package, with two workers by default.
fit_parallel <- segen(time_features[, "IBM.Close", drop = FALSE], seq_len = 12, n_samp = 4, use_parallel = TRUE, parallel_workers = 2)
There are no contributed runtime dependencies. Plot objects now have class
segen_plot; display them with plot() or print(), rather than adding
ggplot2 layers. Numeric gaps use linear interpolation with constant endpoint
extension; categorical gaps use the most frequent observed level. Smoothing
uses degree-one loess with span 0.75 rather than automatic span selection.
These preprocessing changes can change forecasts. Binary entropy now measures
the empirical distribution of zero/one outcomes in natural-log units.
Percentage metrics use percentages and denominators are bounded below by 1e-8.
Intervals use pooled rolling residuals and do not guarantee nominal coverage
under arbitrary temporal dependence.
Input must be a data frame whose columns are all numeric or all categorical.
Dates, when supplied, must be a Date vector with one value per row. Missing
numeric values are imputed before forecasting.
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.