Package {segen}


Type: Package
Title: Sequence Generalization Through Similarity Network
Version: 2.0.1
Description: Proposes an application for sequence prediction generalizing the similarity within the network of previous sequences.
License: GPL-3
Encoding: UTF-8
LazyData: true
Depends: R (≥ 3.6)
Imports: stats, utils, graphics, grDevices, parallel
URL: https://rpubs.com/giancarlo_vercellino/segen
Suggests: testthat (≥ 3.0.0), knitr, rmarkdown
VignetteBuilder: knitr
Config/testthat/edition: 3
Config/roxygen2/version: 8.1.0
RoxygenNote: 7.3.3
NeedsCompilation: no
Packaged: 2026-09-07 16:49:25 UTC; gianc
Author: Giancarlo Vercellino [aut, cre]
Maintainer: Giancarlo Vercellino <giancarlo.vercellino@gmail.com>
Repository: CRAN
Date/Publication: 2026-09-07 17:40:02 UTC

segen

Description

Sequence Generalization Through Similarity Network

Usage

segen(
  df,
  seq_len = NULL,
  similarity = NULL,
  dist_method = NULL,
  rescale = NULL,
  smoother = FALSE,
  ci = 0.8,
  error_scale = "naive",
  error_benchmark = "naive",
  n_windows = 10,
  n_samp = 30,
  dates = NULL,
  seed = 42,
  use_parallel = FALSE,
  parallel_workers = NULL
)

Arguments

df

data.frame of time features (all numeric OR all categorical).

seq_len

integer, forecasting horizon. If NULL, auto-sampled.

similarity

numeric in (0,1), similarity quantile. If NULL, sampled.

dist_method

character. Options: "euclidean","manhattan","maximum","minkowski","correlation","dtw". If NULL, sampled from the six internal distance methods.

rescale

logical, rescale weights before normalization.

smoother

logical, apply loess smoothing for numeric features.

ci

numeric in (0,1), confidence level.

error_scale

"naive" or "deviation".

error_benchmark

"naive" or "average".

n_windows

integer, rolling validation windows.

n_samp

integer, random search samples.

dates

Date vector aligned with rows of df (optional).

seed

integer, RNG seed.

use_parallel

logical, use standard-library PSOCK workers for parallel exploration.

parallel_workers

NULL or integer, number of workers when parallel.

Value

list with exploration, history, best_model, time_log.

This function returns a list including:

Author(s)

Giancarlo Vercellino giancarlo.vercellino@gmail.com

Maintainer: Giancarlo Vercellino giancarlo.vercellino@gmail.com

See Also

Useful links:

Examples

segen(time_features[, 1, drop = FALSE], seq_len = 30, similarity = 0.7, n_windows = 3, n_samp = 1)



Draw a segen forecast

Description

Draw a segen forecast

Usage

## S3 method for class 'segen_plot'
plot(x, ...)

## S3 method for class 'segen_plot'
print(x, ...)

Arguments

x

A forecast plot returned in best_model$plots.

...

Additional arguments passed to the base plot function.

Value

The plot object, invisibly.


time features example: IBM and Microsoft Close Prices

Description

A data frame with with daily with daily prices for IBM and Microsoft since April 2020

Usage

time_features

Format

A data frame with 2 columns and 500 rows.

Source

finance.yahoo.com