This repository contains a PyTorch implementation of a Toeplitz Inversed Covariance based Online Segment (TICOS) model for time series data analysis. The TICOS model is a clustering-based method to learn a time-invariant representation of the time series data.
epoch 1 : 88.40296924708377 % loss: 0.10282601574698536 epoch 2 : 89.59915164369035 % loss: 0.19914760540803442 epoch 3 : 89.82820784729586 % loss: 0.29481664973882954 epoch 4 : 94.57900318133616 % loss: 0.39088429775875166 epoch 5 : 93.84941675503711 % loss: 0.4866015293767571
To use the TICOS model, you will need to provide a dataset of time series data. The XplaneDataset
class in the load_data.py
file provides an example dataset that you can use to test the model.
from load_data import XplaneDataset
dataset = XplaneDataset(delta_t)
To train the TICOS model on your dataset, you can use the TIC
and Loss
classes provided in the TIC.py
file. TIC
is the main model class, which takes as input the number of sensors in the data, the time window size delta_t
, and the number of clusters to use for clustering. Loss
is a custom loss function that incorporates both cross-entropy loss and L1 regularization to encourage sparsity in the learned representation.
from tic import TIC, Loss
net = TIC(num_sensors, delta_t, num_clusters)
loss = Loss(net)
You can then train the model using a PyTorch optimizer such as Adam or SGD, and iterate over your dataset using a PyTorch DataLoader.
updater = torch.optim.Adam(net.parameters(), lr=.01)
dataloader = DataLoader(dataset, batch_size=batch_size, shuffle=True)
for epoch in range(num_epoch):
for batch in dataloader:
X, y = batch
y_hat = net(X)
l = loss(y_hat, y)
updater.zero_grad()
l.backward()
updater.step()
This implementation is derived from the paper "Toeplitz Inverse Covariance-Based Clustering of Multivariate Time Series Data".