uniqed.transformers package¶
Submodules¶
uniqed.transformers.transformers module¶
- class uniqed.transformers.transformers.TimeDelayEmbedder(d=3, tau=1)¶
Bases:
sklearn.base.BaseEstimator,sklearn.base.TransformerMixin- fit(x, y=None)¶
- transform(x)¶
- fit_transform(x, y=None)¶
Fit to data, then transform it.
Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.
- Xarray-like of shape (n_samples, n_features)
Input samples.
- yarray-like of shape (n_samples,) or (n_samples, n_outputs), default=None
Target values (None for unsupervised transformations).
- **fit_paramsdict
Additional fit parameters.
- X_newndarray array of shape (n_samples, n_features_new)
Transformed array.
- _embedding(x, d, tau)¶
Time delay embedding
- Parameters
x (numpy.ndarray) – 1D time series
d (int) – Embedding dimension
tau (int) – Embedding delay
- Returns
Embedded time series with [len(x) - (d - 1) * tau, d] shape
- Return type
numpy.ndarray
- class uniqed.transformers.transformers.TransformYTrue(d=3, tau=1)¶
Bases:
sklearn.base.BaseEstimator,sklearn.base.TransformerMixin- fit(x, y=None)¶
- transform(x)¶
- fit_transform(x, y=None)¶
Fit to data, then transform it.
Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.
- Xarray-like of shape (n_samples, n_features)
Input samples.
- yarray-like of shape (n_samples,) or (n_samples, n_outputs), default=None
Target values (None for unsupervised transformations).
- **fit_paramsdict
Additional fit parameters.
- X_newndarray array of shape (n_samples, n_features_new)
Transformed array.
- _transform_y_true(x)¶
Transforms y_true to shorter version aligned with a specific embedding (d, tau)
- Parameters
x (numpy.ndarray) – array with values
- Returns
array truncated symmetrically at the begining and at the end
- Return type
numpy.ndarray
- _get_faketime_axis(d, tau)¶
Computes a new shifted time-axis for embedded time-series
- Parameters
embededd_time_series (numpy.ndarray) – embedded time series (n x d) array, time instances as rows
embedding_delay (int) – the embedding delay parameter used in the embedding
- Returns
numpy.array with new shifted time-axis
- uniqed.transformers.transformers.invertit(score, doit=False)¶
Inverts score if doit is True
- Parameters
score (np.ndarray) – score to conditionally invert
doit (bool) – invert the score or not (default: False)
- Returns
inverted or original score
- Return type
np.ndarray
- uniqed.transformers.transformers._make_result_df(new_time_axis, outlier_score, y_pred, inv_it, prefix='')¶
Make result dataFrame for detections
- Parameters
new_time_axis (np.ndarray) – truncated time axis after embedding
outlier_score (np.ndarray) – computed outlier scores
y_pred (np.ndarray) – predicted class labels (contains -1s and 1s for the two classes)
inv_it (bool) – wheather invert the outlier score or not
prefix (str) – some prefix to the columns
- Returns
DataFrame with results, in the columns are the score, class_label respectively
- Return type
pandas.DataFrame