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)
#> seq_len similarity dist_method rescale me mae mse rmsse mpe mape
#> 1 12 0.7 maximum TRUE 0.0685 1.835 5.1685 1.452 0.113 1.445
#> rmae rrmse rame mase smse sce gmrae
#> 1 1.047 1.1815 3.0575 1.179 2.1695 -0.1645 0.8035
fit$best_model$predictions$IBM.Close
#> min 10% 25% 50% 75% 90% max mean
#> t1 128.6183 125.7742 128.7988 128.8509 128.9231 131.9276 129.1454 128.8589
#> t2 128.6484 125.9204 128.9130 128.9971 129.0764 132.0738 129.3406 128.9984
#> t3 128.7918 126.0802 129.0801 129.1569 129.2470 132.2336 129.5330 129.1622
#> t4 129.1503 126.4166 129.3947 129.4933 129.5884 132.5700 129.8160 129.4828
#> t5 129.7122 127.1188 130.0598 130.1955 130.3021 133.2722 130.6969 130.1794
#> t6 129.4627 126.9233 129.8495 130.0000 130.1015 133.0767 130.5379 129.9827
#> t7 129.3404 126.8599 129.8026 129.9366 130.0442 133.0133 130.4604 129.9340
#> t8 129.5547 127.0791 130.0224 130.1558 130.3052 133.2325 130.7546 130.1642
#> t9 129.4799 126.8931 129.8000 129.9698 130.1230 133.0465 130.5793 129.9760
#> t10 129.7091 127.1032 130.0202 130.1799 130.3491 133.2566 130.7794 130.1883
#> t11 129.6090 127.0465 129.9307 130.1232 130.2650 133.1999 130.6518 130.1126
#> t12 129.6823 127.0899 129.9744 130.1666 130.2831 133.2433 130.6904 130.1452
#> sd mode kurtosis skewness iqr_to_range above_to_below_range
#> t1 0.1012 128.8568 2.9151 0.1377 0.2358 1.2665
#> t2 0.1171 128.9606 3.0947 0.0013 0.2360 0.9847
#> t3 0.1352 129.1423 3.3662 -0.0512 0.2253 1.0298
#> t4 0.1438 129.4688 2.5950 -0.1567 0.2910 0.9407
#> t5 0.1765 130.2069 3.1770 -0.1353 0.2461 1.0373
#> t6 0.1954 130.0218 3.2804 -0.1571 0.2344 1.0010
#> t7 0.1927 129.9219 3.1341 -0.0985 0.2158 0.8785
#> t8 0.2156 130.1080 3.0738 0.1540 0.2357 0.9963
#> t9 0.2189 130.0001 2.6717 0.2041 0.2938 1.2443
#> t10 0.2311 130.2707 2.3886 0.0832 0.3073 1.2733
#> t11 0.2255 130.1921 2.4771 0.2183 0.3206 1.0279
#> t12 0.2228 130.1534 2.4997 0.1202 0.3062 1.0817
#> upside_prob divergence pred_scores
#> t1 0.3953 0.7718 0.00000
#> t2 0.9690 0.0000 0.01550
#> t3 0.9767 0.0000 0.00000
#> t4 1.0000 0.0000 0.00000
#> t5 1.0000 0.0000 0.00000
#> t6 0.0078 0.4341 0.34110
#> t7 0.2403 0.1628 0.00000
#> t8 1.0000 0.0000 0.00000
#> t9 0.0465 0.3411 0.00000
#> t10 1.0000 0.0000 0.03875
#> t11 0.2248 0.1705 0.00775
#> t12 0.6899 0.0078 0.05425The result contains the model search history, the selected model’s predictions and testing errors, plots, and elapsed-time information.
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.
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.