Open robotdude17 opened 5 years ago
Hi,
The WEASEL transformation is not suited for one single time series: it uses a binning procedure, and binning is pointless when there is one single data point. You need more samples to make it work.
Here is the paper describing the Symbolic Fourier Approximation, which is used in WEASEL. Figure 2 shows the binning process. It cannot work with a single time series.
I hope that it helps you.
I'm trying to get a WEASEL transform of just one single time series and am running into issues, see below.
Please advise.
Thanks.
from pyts.transformation import WEASEL
Parameters
n_samples, n_timestamps = 1, 100 n_classes = 1
Toy dataset
rng = np.random.RandomState(41) X = rng.randn(n_samples, n_timestamps) y = rng.randint(n_classes, size=n_samples)
WEASEL transformation
weasel = WEASEL(word_size = 2, n_bins = 2, window_sizes=[12, 36])
X_weasel = weasel.fit_transform(X, y).toarray()
X_weasel = weasel.fit_transform(X, y)
X_weasel = weasel.fit_transform(np.array(X), np.array(y)).toarray()
Visualize the transformation for the first time series
plt.figure(figsize=(12, 8)) vocabularylength = len(weasel.vocabulary) width = 0.3 plt.bar(np.arange(vocabulary_length) - width / 2, X_weasel[0], width=width, label='First time series') plt.xticks(np.arange(vocabularylength), np.vectorize(weasel.vocabulary.get)(np.arange(X_weasel[0].size)), fontsize=12, rotation=60) plt.yticks(np.arange(np.max(X_weasel[:2] + 1)), fontsize=12) plt.xlabel("Words", fontsize=18) plt.ylabel("Frequencies", fontsize=18) plt.title("WEASEL transformation", fontsize=20) plt.legend(loc='best') plt.show()
ValueError Traceback (most recent call last)