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_pointsand/orn_states.Semi-supervised — given quantities, randomises locations/labels.
Parameters
Name |
Type |
Default |
Description |
|---|---|---|---|
|
bool |
|
Enable semi-supervised mode. |
|
int / None |
|
Number of change points to emit. |
|
int / None |
|
Number of distinct states. |
|
int / 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:
BaseSegmenterRandom 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
fitmethod.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(seesklearn.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 tofitif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it tofit.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.
- set_predict_request(*, axis: bool | None | str = '$UNCHANGED$') RandomDetector
Configure whether metadata should be requested to be passed to the
predictmethod.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(seesklearn.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 topredictif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it topredict.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.