milia.represent.foundation#
Foundation-model embeddings of whole load sequences (Chronos-2).
Each meter’s sequence is embedded by a pretrained time-series model and the per-patch embeddings are pooled into one vector. The pooled vector is a representation for clustering, not a forecast, so it lives here rather than in twiga.
Functions
|
Collapse a per-patch embedding to one vector. |
Classes
|
Chronos-2 sequence embeddings as a scikit-learn transformer. |
- milia.represent.foundation.pool(embedding, pooling)#
Collapse a per-patch embedding to one vector.
- Parameters:
- Return type:
- Returns:
Shape
(dim,).
Examples
>>> pool(np.arange(6.0).reshape(3, 2), "mean").tolist(), pool(np.arange(6.0).reshape(3, 2), "last").tolist() ([2.0, 3.0], [4.0, 5.0])
- class milia.represent.foundation.Foundation(model='amazon/chronos-2', pooling='mean', batch=64, device='cpu')#
Bases:
TransformerMixin,BaseEstimatorChronos-2 sequence embeddings as a scikit-learn transformer.
Each row of
Xis one sequence. The model loads on first use and is not pickled with the estimator.- Parameters:
Examples
>>> import numpy as np >>> Foundation().fit_transform(np.random.default_rng(0).random((4, 96))).shape (4, 768)
- fit(X, y=None)#
Record the sequence length; the model itself is pretrained and not fitted.
- Parameters:
- Return type:
- Returns:
The estimator.
- pipeline()#
The loaded Chronos pipeline, downloaded and cached on first use.
- Returns:
The
chronos.Chronos2Pipeline.- Raises:
MissingExtraError – If the
foundationextra is not installed.