sciedm.EmbedDimension#

class sciedm.EmbedDimension(columns=None, target=None, maxE=10, lib=None, pred=None, Tp=1, tau=-1, exclusionRadius=0, embedded=False, noTime=False, mpMethod=None, chunksize=1, n_jobs=10)#

Evaluate time delay embedding dimension of column : target

This class is a wrapper for Simplex. The goal is to estimate the optimal time-delay embedding dimension E for use in Simplex, SMap and CCM. A list of candidate embedding dimensions from 1-maxE is used to evaluate simplex predictability. The embedding dimension where predictability saturates can be considered a viable estimate of E.

Both time series columns & target must be present as named columns in X. columns and target can be the same representing a univariate observation, or can be different in which case the variables are cross mapped with columns as the shadow manifold source and target the variable to predict.

Parameters:
columns[str]

Vector of column names to create embedding library

targetstr

DataFrame column name of target feature to predict

maxEint

Maximum embedding dimension applied in time delay embedding

lib[int]

Vector of pairs of 1-offset integer indices defining the embedding library The first index of a pair is the start index, the second the stop index. Default lib=None will assign lib=[1,N_obs] where N_obs is the number of observations. lib is _not_ 0-offset but ranges from 1 to N_obs.

pred[int]

Vector of pairs of 1-offset integer indices defining target prediction times The first index of a pair is the start index, the second the stop index. Default pred=None will assign pred=[1,N_obs] where N_obs is the number of observations. pred is _not_ 0-offset but ranges from 1 to N_obs.

tauint

Embedding time delay offset. Negative are delays, positive future values.

Tpint

Prediction horizon in units of time series row indices

exclusionRadiusint

Temporal exclusion radius for nearest neighbors. Neighbors closer than exclusionRadius indices from the target are ignored. Not applicable if lib and pred are disjoint.

embeddedbool

Is the input an embedding? If False (default) all columns will be time delay embedded with E and tau.

noTimebool

X is expected to be DataFrame with time index/values/strings in first column. If no time vector is provided set noTime=True.

mpMethodstr

Multiprocessing context start method See: docs.python.org/3/library/multiprocessing.html#contexts-and-start-methods

Attributes:
is_fitted_bool

A boolean indicating whether the estimator has been fitted.

n_features_in_int

Number of features seen during fit.

feature_names_in_ndarray of shape (n_features_in_,)

Names of features seen during fit. Defined only when X has feature names that are all strings.

E_rho_DataFrame

DataFrame of embedding dimension and maximal simplex predictive correlation

Returns:

Examples

>>> from sciedm import EmbedDimension
>>> from pandas import read_csv
>>> df = read_csv('data/S12CD-S333-SumFlow_1980-2005.csv')
>>> embd = EmbedDimension(columns='SumFlow', target='SumFlow',
                          lib=[1,700], pred=[701,1379], Tp=3)
>>> EDim = embd.fit_transform(df)
>>> from aux_func import PlotEmbedDimension
>>> PlotEmbedDimension(EDim, Tp=embd.Tp)
SimplexE(E, data, args)#

Simplex at embedding dimension E

fit(X, y=None)#

This method does no work. It copies mutable parameters and sets some feature objects for scikit-learn compatibility. It does not call validate_data() as it is called in transform and again in each Simplex object.

Parameters:
X{array-like}, shape (n_samples, n_features)

Observed data to be embedded, or used as embedding.

yaccepted but silently ignored
Returns:
selfobject

Returns self.

fit_transform(X, y=None, **fit_params)#

Fit to data, then transform it.

Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.

Parameters:
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. Pass only if the estimator accepts additional params in its fit method.

Returns:
X_newndarray array of shape (n_samples, n_features_new)

Transformed array.

get_feature_names_out(input_features=None)#

set_output for downstream pipeline compatibility

The ‘output’ is a DataFrame with [E. rho]

get_metadata_routing()#

Get metadata routing of this object.

Please check User Guide on how the routing mechanism works.

Returns:
routingMetadataRequest

A MetadataRequest encapsulating routing information.

get_params(deep=True)#

Get parameters for this estimator.

Parameters:
deepbool, default=True

If True, will return the parameters for this estimator and contained subobjects that are estimators.

Returns:
paramsdict

Parameter names mapped to their values.

set_output(transform='pandas')#

Set output container.

See Introducing the set_output API for an example on how to use the API.

Parameters:
transform{“default”, “pandas”, “polars”}, default=None

Configure output of transform and fit_transform.

  • "default": Default output format of a transformer

  • "pandas": DataFrame output

  • "polars": Polars output

  • None: Transform configuration is unchanged

Added in version 1.4: "polars" option was added.

Returns:
selfestimator instance

Estimator instance.

set_params(**params)#

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as Pipeline). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

Parameters:
**paramsdict

Estimator parameters.

Returns:
selfestimator instance

Estimator instance.

transform(X)#

Use multiprocessing pool to evaluate embedding dimensions from 1 to maxE with a Simplex predictor.

A list of embedding dimensions Evals holds the E to be evaluated for simplex predictive fidelity. The list is used to create the _poolArgs iterable fed to a multiprocessing context which executes the SimplexE() function for each iterable item.

Parameters:
X{array-like}, shape (n_samples, n_features)

Passed to instances of class Simplex: see simplex.py

Returns:
DataFrame

[E,rho]