tsseg.algorithms.tire package
TIRE — Time-Invariant Representation for change point detection.
Description
TIRE learns a compact representation by training ensembles of parallel autoencoders in both the time domain (TD) and frequency domain (FD). The shared latent dimensions across autoencoders capture the time-invariant signal statistics while the private dimensions capture time-varying noise. A dissimilarity curve is computed from the shared representations and peaks in this curve indicate change points.
By tuning the loss weights and latent dimensions for each domain you can control whether the detector focuses on amplitude changes (TD) or spectral changes (FD) or both.
Parameters
Name |
Type |
Default |
Description |
|---|---|---|---|
|
int |
|
Sliding window size (>= 4). |
|
int |
|
Stride between consecutive windows. |
|
str |
|
Domain(s) for representation learning ( |
|
int |
|
Hidden dim of TD autoencoder (0 = skip intermediate layer). |
|
int |
|
Latent dim of TD autoencoder. |
|
int |
|
Number of shared latent dims (TD). |
|
int |
|
Number of parallel TD autoencoders. |
|
float |
|
Loss weight for TD component. |
|
int |
|
Hidden dim of FD autoencoder. |
|
int |
|
Latent dim of FD autoencoder. |
|
int |
|
Number of shared latent dims (FD). |
|
int |
|
Number of parallel FD autoencoders. |
|
float |
|
Loss weight for FD component. |
|
int |
|
FFT size for frequency-domain windows. |
|
str |
|
Normalisation scope ( |
|
float |
|
Min fraction of series length between peaks. |
|
int |
|
Maximum training epochs. |
|
int |
|
Early-stopping patience. |
|
float |
|
Optimiser learning rate. |
|
int / None |
|
Number of segments (overrides peak detection). |
|
int |
|
Time axis. |
|
int / None |
|
Random seed. |
Usage
from tsseg.algorithms import TireDetector
detector = TireDetector(window_size=30, domain="both", n_segments=5)
labels = detector.fit_predict(X)
Implementation: Origin: new code.
Reference: De Ryck, De Vos, Bertrand & Verhoest (2021), Change Point Detection in Time Series Data Using Autoencoders with a Time-Invariant Representation, IEEE TSIPN.
Submodules
tsseg.algorithms.tire.detector module
- class tsseg.algorithms.tire.detector.TireDetector(window_size=20, stride=1, domain='both', intermediate_dim_td=0, latent_dim_td=1, nr_shared_td=1, nr_ae_td=3, loss_weight_td=1.0, intermediate_dim_fd=10, latent_dim_fd=1, nr_shared_fd=1, nr_ae_fd=3, loss_weight_fd=1.0, nfft=30, norm_mode='timeseries', peak_distance_fraction=0.01, max_epochs=20, patience=5, learning_rate=0.001, *, n_segments=None, axis=0, random_state=None)[source]
Bases:
BaseSegmenterTIRE (Time-Invariant Representation) change point detector.
- set_fit_request(*, axis: bool | None | str = '$UNCHANGED$') TireDetector
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$') TireDetector
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.tire.utils module
- tsseg.algorithms.tire.utils.calc_fft(windows, nfft=30, norm_mode='timeseries')[source]
Calculates the DFT for each window and transforms its length
- Parameters:
windows – time series windows
nfft – number of points used for the calculation of the DFT
norm_mode – ensure that the timeseries / each window has zero mean
- Returns:
frequency domain windows, each window having size nfft//2 (+1 for timeseries normalization)
- tsseg.algorithms.tire.utils.combine_ts(list_of_windows)[source]
Combines a list of windows from multiple views to one list of windows
- Parameters:
list_of_windows – list of windows from multiple views
- Returns:
one array with the concatenated windows
- tsseg.algorithms.tire.utils.cp_to_timestamps(changepoints, tolerance, length_ts)[source]
Extracts time stamps of change points
- Parameters:
changepoints
tolerance
length_ts – length of original time series
- Returns:
list where each entry is a list with the windows affected by a change point
- tsseg.algorithms.tire.utils.distance(data, window_size)[source]
Calculates distance (dissimilarity measure) between features
- Parameters:
data – array of of learned features of size (nr. of windows) x (number of shared features)
window_size – window size used for CPD
- Returns:
Array of dissimilarities of size ((nr. of windows)-stride)
- tsseg.algorithms.tire.utils.matched_filter(signal, window_size)[source]
Matched filter for dissimilarity measure smoothing (and zero-delay weighted moving average filter for shared feature smoothing)
- Parameters:
signal – input signal
window_size – window size used for CPD
- Returns:
filtered signal
- tsseg.algorithms.tire.utils.new_peak_prominences(distances)[source]
Adapted calculation of prominence of peaks, based on the original scipy code
- Parameters:
distances – dissimarity scores
- Returns:
prominence scores
- tsseg.algorithms.tire.utils.parameters_to_cps(parameters, window_size)[source]
Preparation for plotting ground-truth change points
- Parameters:
parameters – array parameters used to generate time series, size Tx(nr. of parameters)
window_size – window size used for CPD
- Returns:
Array of which entry is non-zero in the presence of a change point. Higher values correspond to larger parameter changes.
- tsseg.algorithms.tire.utils.tpr_fpr(bps, distances, method='prominence', tol_dist=0)[source]
Calculation of TPR and FPR
- Parameters:
bps – list of breakpoints (change points)
distances – list of dissimilarity scores
method – prominence- or height-based change point score
tol_dist – toleration distance
- Returns:
list of TPRs and FPRs for different values of the detection threshold