tsseg.algorithms.random package

Random — baseline detector for benchmarking.

Description

Emits uniformly random change points or state labels. Intended as a lower bound for benchmarks and for pipeline testing.

Two modes of operation:

  • Unsupervised — draws a random n_change_points and/or n_states.

  • Semi-supervised — given quantities, randomises locations/labels.

Type: state detection
Supervision: unsupervised or semi-supervised
Scope: univariate and multivariate

Parameters

Name

Type

Default

Description

semi_supervised

bool

False

Enable semi-supervised mode.

n_change_points

int / None

None

Number of change points to emit.

n_states

int / None

None

Number of distinct states.

random_state

int / None

None

Random seed for reproducibility.

Usage

from tsseg.algorithms import RandomDetector

detector = RandomDetector(n_change_points=5, random_state=42)
labels = detector.fit_predict(X)

Implementation: Origin: new code.

Reference:

Submodules

tsseg.algorithms.random.detector module

Random detector producing synthetic states and change points.

class tsseg.algorithms.random.detector.RandomDetector(*, semi_supervised=False, n_change_points=None, n_states=None, random_state=None)[source]

Bases: BaseSegmenter

Random detector emitting change points and state labels.

The detector is primarily intended for testing pipelines. It can operate in a purely unsupervised fashion, where the number of change points and states is drawn at random (with bounds derived from available data), or in a semi-supervised mode where those quantities are given but locations and assignments remain random.

set_fit_request(*, axis: bool | None | str = '$UNCHANGED$') RandomDetector

Configure whether metadata should be requested to be passed to the fit method.

Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with enable_metadata_routing=True (see sklearn.set_config()). Please check the User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to fit if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to fit.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

Added in version 1.3.

Parameters:

axis (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for axis parameter in fit.

Returns:

self – The updated object.

Return type:

object

set_predict_request(*, axis: bool | None | str = '$UNCHANGED$') RandomDetector

Configure whether metadata should be requested to be passed to the predict method.

Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with enable_metadata_routing=True (see sklearn.set_config()). Please check the User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to predict if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to predict.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

Added in version 1.3.

Parameters:

axis (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for axis parameter in predict.

Returns:

self – The updated object.

Return type:

object

Module contents