sciedm.CCM_Matrix#
- class sciedm.CCM_Matrix(E, libSizes=[], pLibSizes=[10, 20, 80, 90], Tp=0, tau=-1, exclusionRadius=0, sample=30, seed=None, noTime=False, parallel=True, mpMethod=None, sharedMB=0.01, targetBatchSize=None, expConverge=False, progressLog=None, progressInterval=5)#
Compute the full M×M×L convergent cross mapping tensor.
- Parameters:
- Eint or array-like of int
Embedding dimension. Scalar or per-column vector of length M.
- Tpint
Prediction horizon. Default 0.
- tauint
Embedding delay. Default -1.
- exclusionRadiusint
Temporal exclusion radius. Default 0.
- libSizeslist of int
Explicit library sizes. If non-empty, used directly and pLibSizes is ignored. Default [].
- pLibSizeslist of float
Percentiles of N to generate library sizes. Used only when libSizes is empty. Default [10, 20, 80, 90].
- sampleint
Subsamples per library size. Default 100.
- seedint or None
RNG seed.
- noTimebool
If True, all columns are data. If False, first column is time (stripped). Default False.
- parallelbool or int
Worker count. Default True.
- mpMethodstr or None
Multiprocessing start method: ‘forkserver’ or ‘spawn’ only. Default None.
- sharedMBfloat
Data size threshold for shared memory vs pickle. Default 5.
- targetBatchSizeint or None
Max target columns per batch within each worker. Default None.
- expConvergebool
If True, fit exponential convergence curve. Default False.
- progressLogNone, True, or str
None: no logging. True: log to stderr. str: log to file path. Default None.
- progressIntervalint
Percentage increment for progress log lines. Default 5.
- The slope of CCM rho(libSizes) is computed based on a [0,1]
- normalization of libSizes.
- if expConverge = True a nonlinear convergence function is fit
- to rho(libSizes)y0 + b * ( 1 - exp(-a * x) ) with fit coefficient
- a returned in the (M, M) matrix self.exp_a
- 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
Xhas feature names that are all strings.- tensor_ndarray, float16
(M, M, L) array of MxM CCM matrices at the L libSizes
- slope_ndarray, float32
(M, M) array of CCM rho ~ LibSizes
- exp_a_ndarray, float32
(M, M) array of exponential fit coefficient or None
- columns_[str]
List of columns/rows of the CCM and slope matrices
- lib_sizes_arr_ndarray
Integer libSizes
- lib_sizes_norm_ndarray
Normalized [0,1] libSizes for slope regression
- Returns:
- tuple (MxMxL tensor, columns, libSizes)
Examples
>>> from sciedm import CCM_Matrix, PlotMatrix >>> from pandas import DataFrame >>> X = np.random.rand(10,10) >>> df = DataFrame(X,columns=[f"x{i+1}" for i in range(10)]) >>> cmat = CCM_Matrix(E=4,noTime=True) >>> tensor,columns = cmat.fit_transform(df) >>> PlotMatrix(tensor[:,:,2],columns)
- Run()#
Compute the M×M×L CCM tensor, linear convergence slope, and (optionally) exponential convergence rate.
- Returns:
- tensorndarray (M, M, |L|), float16
- Validate()#
Parse DataFrame, extract data, resolve E and library sizes.
- fit(X, y=None)#
Initialize lib & pred indices, embed data, find neighbors
- Parameters:
- X{array-like}, shape (n_samples, n_features)
Observed data to be embedded, or used as embedding.
- yaccepted but silently ignored — embedding is target-independent
- Returns:
- selfobject
Returns self.
- fit_transform(X, y=None, **fit_params)#
Fit to data, then transform it.
Fits transformer to
Xandywith optional parametersfit_paramsand returns a transformed version ofX.- 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
fitmethod.
- 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 MxMxL tensor with M columns_ names
- get_metadata_routing()#
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
- Returns:
- routingMetadataRequest
A
MetadataRequestencapsulating 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=None)#
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
transformandfit_transform."default": Default output format of a transformer"pandas": DataFrame output"polars": Polars outputNone: 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)#
Call CrossMap() for forward and reverse mappings.
The output is independent of the specific X passed here (CCM was fit on the training X); this method exists so the estimator participates correctly in sklearn Pipelines.
- Parameters:
- X{array-like}, shape (n_samples, n_features)
Not used but accepted for sklearn convention.
- Returns:
- tuple: MxMxL tensor, columns, libSizes