Random (baseline)#
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. |
|
int |
|
Time axis (rows with |
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: none.
API reference#
Random detector producing synthetic states and change points.
- class RandomDetector(*, semi_supervised=False, n_change_points=None, n_states=None, random_state=None, axis=0)[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.
- Parameters:
semi_supervised (
bool) – IfTrue,n_change_pointsandn_statesare required and used as given. IfFalse, both counts are drawn at random and these two parameters are ignored.n_change_points (
int|None) – Number of change points, used whensemi_supervised=True; at mostn - 1for a series ofnpoints.0gives a single segment.n_states (
int|None) – Number of distinct states, used whensemi_supervised=True; at least 2 when there is a change point.random_state (
int|None) – Seed of the random generator, drawn again at eachfit.Nonegives a different segmentation at eachfit.axis (
int) – Time axis: rows with0, columns with1.
Notes
Without
semi_supervised, the number of change points is drawn uniformly in {3, …, min(14, n - 1)} (n - 1change points ifn < 4) and the number of states uniformly in {min(n_change_points + 1, 10), …, 10}. Change points are drawn without replacement among 1, …, n - 1, and two consecutive segments never share a state.predicton a series whose length differs from the one seen byfitdraws a new segmentation.- set_fit_request(*, axis='$UNCHANGED$')#
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='$UNCHANGED$')#
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.