Meta-Learning for Time Series Forecasting
Project description
MetaTS | Meta-Learning for Global Time Series Forecasting
Features
- Generating meta features
- Statistical features : TsFresh, User defined features
- Automated feature extraction using Deep Unsupervised Learning : Deep AutoEncoder (MLP, LSTM, GRU, ot custom model)
- Supporting sktime and darts libraries for base-forecasters
- Providing a Meta-Learning pipeline
Quick Start
Installing the package
pip install metats
Generating a toy dataset by sampling from two different processes
from metats.datasets import ETSDataset
ets_generator = ETSDataset({'A,N,N': 512,
'M,M,M': 512}, length=30, freq=4)
data, labels = ets_generator.load(return_family=True)
colors = list(map(lambda x: (x=='A,N,N')*1, labels))
Normalizing the time series
from sklearn.preprocessing import StandardScaler
scaled_data = StandardScaler().fit_transform(data.T)
data = scaled_data.T[:, :, None]
Checking How data looks like
import matplotlib.pyplot as plt
_ = plt.plot(data[10, :, 0])
Generating the meta-features
Statistical features using TsFresh
from metats.features.statistical import TsFresh
stat_features = TsFresh().transform(data)
Deep Unsupervised Features
Training an AutoEncoder
from metats.features.unsupervised import DeepAutoEncoder
from metats.features.deep import AutoEncoder, MLPEncoder, MLPDecoder
enc = MLPEncoder(input_size=1, input_length=30, latent_size=8, hidden_layers=(16,))
dec = MLPDecoder(input_size=1, input_length=30, latent_size=8, hidden_layers=(16,))
ae = AutoEncoder(encoder=enc, decoder=dec)
ae_feature = DeepAutoEncoder(auto_encoder=ae, epochs=150, verbose=True)
ae_feature.fit(data)
Generating features using the auto-encoder
deep_features = ae_feature.transform(data)
Visualizing both statistical and deep meta-features
Dimensionality reduction using UMAP for visualization
from umap import UMAP
deep_reduced = UMAP().fit_transform(deep_features)
stat_reduced = UMAP().fit_transform(stat_features)
Visualizing the statistical features:
plt.scatter(stat_reduced[:512, 0], stat_reduced[:512, 1], c='#e74c3c', label='ANN')
plt.scatter(stat_reduced[512:, 0], stat_reduced[512:, 1], c='#9b59b6', label='MMM')
plt.legend()
plt.title('TsFresh Meta-Features')
_ = plt.show()
And similarly the auto encoder's features
plt.scatter(deep_reduced[:512, 0], deep_reduced[:512, 1], c='#e74c3c', label='ANN')
plt.scatter(deep_reduced[512:, 0], deep_reduced[512:, 1], c='#9b59b6', label='MMM')
plt.legend()
plt.title('Deep Unsupervised Meta-Features')
_ = plt.show()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
metats-0.1.5.tar.gz
(13.7 kB
view details)
Built Distribution
metats-0.1.5-py3-none-any.whl
(14.8 kB
view details)
File details
Details for the file metats-0.1.5.tar.gz
.
File metadata
- Download URL: metats-0.1.5.tar.gz
- Upload date:
- Size: 13.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 75e0ed9a2e8aa20a6b972151ad14f035bf332745fc44fb6871653a38daabbaa5 |
|
MD5 | 087395a441d0a382618056900df74e78 |
|
BLAKE2b-256 | 7f2bd06b0e7b2922630253aa8922bf362ea8efd65609113252c782b55df4046a |
File details
Details for the file metats-0.1.5-py3-none-any.whl
.
File metadata
- Download URL: metats-0.1.5-py3-none-any.whl
- Upload date:
- Size: 14.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2586d9a227a0fe8d39d580fbfcca195e583daa39247d750d4f8ce3b44e557198 |
|
MD5 | 9e428bfcb76b44c79ae89112cda89971 |
|
BLAKE2b-256 | 51c8221c60a3affc00cb51b02a54b766c0149f71322cfc7232f83c12a0558603 |