johannfaouzi / pyts

A Python package for time series classification

Home Page:https://pyts.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Learning Shapelets

Koenig128 opened this issue · comments

Hi,

thank you very much for this great library! I have a general question and would appreciate your support:
I have a single univariate time series and I am trying to use the classification algorithm for learning shaplets.

import pandas as pd
import numpy as np
from pyts.classification import LearningShapelets

np.random.seed(42)
random_data = np.random.randn(100)
df = pd.DataFrame({'column': random_data})

X = [df[col].tolist() for col in df.columns]
clf = LearningShapelets(random_state=42)
y = [1]

clf.fit(X, y)

Now, using the following code I can get the shapelets:

clf.shapelets_

Is there also a way to find where those shapelets were identified in the original time series? Ideally, I would like to map the shapelets back onto the original time series.

Thank you very much in advance for your support!

Hi,

One cannot perform classification with a single sample. One needs at least one sample from each class, and at least two classes, to perform classification.