sciedm.PredictNonlinear#

class sciedm.PredictNonlinear(columns=None, target=None, theta=[0.01, 0.1, 0.3, 0.5, 0.75, 1, 1.5, 2, 3, 4, 5, 6, 7, 8, 9], E=1, lib=None, pred=None, Tp=1, tau=-1, exclusionRadius=0, embedded=False, noTime=False, mpMethod=None, chunksize=1, n_jobs=10)#

Evaluate nonlinearity (state-dependence)

This class is a wrapper for SMap. The goal is to estimate the optimal SMap localization parameter theta.

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

theta[float]

Vector of theta values, theta >= 0.

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.

theta_rho_DataFrame

DataFrame of SMap rho(theta)

Returns:

Examples

>>> from sciedm import PredictNonlinear
>>> from pandas import read_csv
>>> df = read_csv('data/S12CD-S333-SumFlow_1980-2005.csv')
>>> pnl = PredictNonlinear(columns='SumFlow', target='SumFlow', E=3,
                          lib=[1,700], pred=[701,1379], Tp=3)
>>> thetaRho = pnl.fit_transform(df)
>>> from aux_func import PlotPredictNonlinear
>>> PlotPredictNonlinear(thetaRho, E=pnl.E, Tp=pnl.Tp)
SMapTheta(theta, data, args)#

SMap prediction with theta

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 [theta, 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 theta with a SMap 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

[theta, rho]