tsseg.algorithms.ticc package
TICC — Toeplitz Inverse Covariance-based Clustering.
Description
TICC simultaneously segments and clusters multivariate time series by modelling
each cluster as a Markov Random Field (MRF) defined over a short window of
length window_size. The MRF is characterised by a block-Toeplitz inverse
covariance matrix that captures temporal and cross-variable partial correlations.
The algorithm alternates between:
Assignment step — dynamic programming assigns each time step to the cluster maximising a log-likelihood + switching penalty \(\beta\).
Update step — ADMM updates the Toeplitz inverse covariance of each cluster subject to a sparsity penalty \(\lambda\).
n_states required)Parameters
Name |
Type |
Default |
Description |
|---|---|---|---|
|
int |
|
Sliding window size. |
|
int |
|
Number of states (clusters). |
|
float |
|
Sparsity parameter for the inverse covariance. |
|
float |
|
Switching penalty (temporal consistency). |
|
int |
|
Maximum EM iterations. |
|
float |
|
Convergence threshold. |
|
int |
|
Number of parallel processes. |
|
int |
|
Time axis. |
Usage
from tsseg.algorithms import TiccDetector
detector = TiccDetector(n_states=4, window_size=10, beta=200)
states = detector.fit_predict(X)
Implementation: Adapted from the original TICC code by Hallac et al.
Reference: Hallac, Vare, Boyd & Leskovec (2017), Toeplitz Inverse Covariance-Based Clustering of Multivariate Time Series Data, KDD.
Submodules
tsseg.algorithms.ticc.detector module
This module provides an aeon-compatible wrapper for the TICC algorithm.
- class tsseg.algorithms.ticc.detector.TiccDetector(window_size=10, n_states=5, lambda_parameter=0.11, beta=400, maxIters=100, threshold=2e-05, num_proc=1, axis=0)[source]
Bases:
BaseSegmenterAn aeon-compatible wrapper for the TICC (Toeplitz Inverse Covariance-based Clustering) algorithm for time series segmentation.
- Parameters:
window_size (int, default=10) – The size of the sliding window.
n_states (int, default=5) – The number of states (clusters) to find.
lambda_parameter (float, default=11e-2) – Sparsity parameter.
beta (float, default=400) – Switching penalty, controls the temporal consistency.
maxIters (int, default=100) – Maximum number of iterations for the TICC solver.
threshold (float, default=2e-5) – Convergence threshold.
num_proc (int, default=1) – Number of processes to use for parallel computation.
axis (int, default=0) – The axis of the input series to segment.
- set_fit_request(*, axis: bool | None | str = '$UNCHANGED$') TiccDetector
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$') TiccDetector
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.
tsseg.algorithms.ticc.ticc module
- class tsseg.algorithms.ticc.ticc.ADMMSolver(lamb, num_stacked, size_blocks, rho, S, rho_update_func=None)[source]
Bases:
object
- class tsseg.algorithms.ticc.ticc.TICC(window_size=10, number_of_clusters=5, lambda_parameter=0.11, beta=400, maxIters=1000, threshold=2e-05, write_out_file=False, prefix_string='', num_proc=1, compute_BIC=False, cluster_reassignment=20, biased=False)[source]
Bases:
object- compute_f_score(matching_EM, matching_GMM, matching_Kmeans, train_confusion_matrix_EM, train_confusion_matrix_GMM, train_confusion_matrix_kmeans)[source]
- compute_matches(train_confusion_matrix_EM, train_confusion_matrix_GMM, train_confusion_matrix_kmeans)[source]
- fit_transform(series)[source]
Main method for TICC solver. :param - input_file: location of the data file
- optimize_clusters(computed_covariance, len_train_clusters, log_det_values, optRes, train_cluster_inverse)[source]
- predict_clusters(test_data=None)[source]
Given the current trained model, predict clusters. If the cluster segmentation has not been optimized yet, than this will be part of the interative process.
- Parameters:
data (numpy array of data for which to predict clusters. Columns are dimensions of the)
is (each row)
timestamp (a different)
- Returns:
vector of predicted cluster for the points
- tsseg.algorithms.ticc.ticc.computeBIC(K, T, clustered_points, inverse_covariances, empirical_covariances)[source]
empirical covariance and inverse_covariance should be dicts K is num clusters T is num samples
- tsseg.algorithms.ticc.ticc.compute_confusion_matrix(num_clusters, clustered_points_algo, sorted_indices_algo)[source]
computes a confusion matrix and returns it
- tsseg.algorithms.ticc.ticc.getTrainTestSplit(m, num_blocks, num_stacked)[source]
Compute the training indices for the TICC model.