WEASELMUSE#
- class pyts.multivariate.transformation.WEASELMUSE(word_size: int = 4, n_bins: int = 4, window_sizes: ArrayLike | None = None, window_steps: ArrayLike | None = None, anova: bool = False, drop_sum: bool = True, norm_mean: bool = True, norm_std: bool = True, strategy: Literal['uniform', 'quantile', 'normal', 'entropy'] = 'quantile', chi2_threshold: int | float = 2, sparse: bool = True, alphabet: str | ArrayLike | None = None)[source]#
WEASEL+MUSE algorithm.
- Parameters:
- word_sizeint (default = 4)
Size of each word.
- n_binsint (default = 4)
The number of bins to produce. It must be between 2 and 26.
- window_sizesarray-like (default = [0.1, 0.3, 0.5, 0.7, 0.9])
Size of the sliding windows. All the elements must be either integers or floats. In the latter case, each element represents the percentage of the size of each time series and must be between 0 and 1; the size of the sliding windows will be computed as
np.ceil(window_sizes * n_timestamps).- window_stepsNone or array-like (default = None)
Step of the sliding windows. If None, each
window_stepis equal towindow_sizeso that the windows are non-overlapping. Otherwise, all the elements must be either integers or floats. In the latter case, each element represents the percentage of the size of each time series and must be between 0 and 1; the step of the sliding windows will be computed asnp.ceil(window_steps * n_timestamps).- anovabool (default = False)
If True, the Fourier coefficient selection is done via a one-way ANOVA test. If False, the first Fourier coefficients are selected.
- drop_sumbool (default = True)
If True, the first Fourier coefficient (i.e. the sum of the subseries) is dropped. Otherwise, it is kept.
- norm_meanbool (default = True)
If True, center each subseries before scaling.
- norm_stdbool (default = True)
If True, scale each subseries to unit variance.
- strategystr (default = ‘quantile’)
Strategy used to define the widths of the bins:
‘uniform’: All bins in each sample have identical widths
‘quantile’: All bins in each sample have the same number of points
‘normal’: Bin edges are quantiles from a standard normal distribution
‘entropy’: Bin edges are computed using information gain
- chi2_thresholdint or float (default = 2)
The threshold used to perform feature selection. Only the words with a chi2 statistic above this threshold will be kept.
- sparsebool (default = True)
Return a sparse matrix if True, else return an array.
- alphabetNone, ‘ordinal’ or array-like, shape = (n_bins,)
Alphabet to use. If None, the first n_bins letters of the Latin alphabet are used.
- Attributes:
- vocabulary_dict
A mapping of features indices to terms. Each value is a string with 4 values separated by a whitespace:
- ‘o’ or ‘d’: whether the word is extracted from the original
time series (‘orig’) or from the derivates (‘diff’)
int : feature index
int : window size
str : word
References
[1]P. Schäfer, and U. Leser, “Multivariate Time Series Classification with WEASEL+MUSE”. Proceedings of ACM Conference, (2017).
Examples
>>> from pyts.datasets import load_basic_motions >>> from pyts.multivariate.transformation import WEASELMUSE >>> X_train, X_test, y_train, y_test = load_basic_motions(return_X_y=True) >>> transformer = WEASELMUSE(sparse=False) >>> transformer.fit_transform(X_train, y_train) array(...)
Methods
__init__([word_size, n_bins, window_sizes, ...])fit(X, y)Fit the model according to the given training data.
fit_transform(X, y)Fit the data then transform it.
get_metadata_routing()Get metadata routing of this object.
get_params([deep])Get parameters for this estimator.
set_params(**params)Set the parameters of this estimator.
transform(X)Transform the provided data.
- __init__(word_size: int = 4, n_bins: int = 4, window_sizes: ArrayLike | None = None, window_steps: ArrayLike | None = None, anova: bool = False, drop_sum: bool = True, norm_mean: bool = True, norm_std: bool = True, strategy: Literal['uniform', 'quantile', 'normal', 'entropy'] = 'quantile', chi2_threshold: int | float = 2, sparse: bool = True, alphabet: str | ArrayLike | None = None) None[source]#
- fit(X: ArrayLike, y: ArrayLike) Self[source]#
Fit the model according to the given training data.
- Parameters:
- Xarray-like, shape = (n_samples, n_features, n_timestamps)
Multivariate time series.
- yarray-like, shape = (n_samples,)
Class labels.
- Returns:
- selfobject
- fit_transform(X: ArrayLike, y: ArrayLike) csr_matrix | NDArray[Any][source]#
Fit the data then transform it.
- Parameters:
- Xarray-like, shape = (n_samples, n_features, n_timestamps)
Multivariate time series.
- yarray-like, shape = (n_samples,)
Class labels.
- Returns:
- X_newarray, shape = (n_samples, n_features_new)
Document-term matrix with relevant features only.
- transform(X: ArrayLike) csr_matrix | NDArray[Any][source]#
Transform the provided data.
- Parameters:
- Xarray-like, shape = (n_samples, n_features, n_timestamps)
Multivariate time series.
- Returns:
- X_newsparse matrix, shape = (n_samples, n_features_new)
Document-term matrix with relevant learned features only.