tsseg.algorithms.patss package

PaTSS — Pattern-based Time Series Segmentation.

Description

PaTSS detects states in time series by mining frequent temporal patterns, building a pattern-based embedding matrix, and clustering the resulting features. The pipeline consists of three stages:

  1. Pattern mining — extracts frequent sub-patterns from the series using configurable length, frequency and overlap parameters.

  2. Embedding — constructs a binary or frequency-based embedding matrix where each row is a time step and each column a mined pattern.

  3. Segmentation — applies a segmentation algorithm (default: logistic regression classifier) on the embedding to partition the series into states.

All configuration is passed through a config dictionary.

Type: state detection
Supervision: fully unsupervised
Scope: univariate and multivariate

Parameters

Name

Type

Default

Description

config

dict / None

None

Settings for PaTSS. If None, default hyperparameters are used. Keys include "pattern_length", "min_frequency", "max_overlap", "n_segments" and classifier settings.

axis

int

0

Time axis (input assumed (n_timepoints, n_channels)).

Usage

from tsseg.algorithms import PatssDetector

detector = PatssDetector()       # default config
states = detector.fit_predict(X)

# Custom config
detector = PatssDetector(config={"pattern_length": 20, "n_segments": 5})
states = detector.fit_predict(X)

Implementation: Adapted from the original PaTSS code.

Reference:

Subpackages

Submodules

tsseg.algorithms.patss.detector module

This module provides a wrapper for the PaTSS algorithm to integrate it with the tsseg library’s API, following the aeon BaseSegmenter structure.

class tsseg.algorithms.patss.detector.PatssDetector(config=None, axis=0)[source]

Bases: BaseSegmenter

A wrapper for the PaTSS (Pattern-based Time Series Segmentation) algorithm, compatible with the aeon framework.

This implementation uses the original logic from PaTSS_perso.py and adapts it to the BaseSegmenter API.

Parameters:
  • config (dict) – A dictionary containing the settings to use within PaTSS. If not provided, the default hyperparameters defined in PaTSS_perso.py will be used.

  • axis (int) – The axis of the time series data. Assumes (n_timepoints, n_channels).

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

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$') PatssDetector

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