skfolio.seriation.BaseSeriation#
- class skfolio.seriation.BaseSeriation[source]#
Base class for estimators that order assets from a distance matrix.
A NaN diagonal marks an asset as non-investable for the current ordering. The matrix restricted to investable assets must be finite, symmetric and nonnegative, with a zero diagonal, within the tolerances described below. DataFrame row and column labels must match in the same order.
- Attributes:
- ordering_ndarray of shape (n_investable_assets,)
Positions in the original input matrix, listed in the computed order. Each investable asset appears exactly once. Empty when no assets are investable. A single investable asset produces its original position.
- investable_mask_ndarray of shape (n_assets,)
Boolean mask selecting investable assets for the current ordering.
- n_features_in_int
Number of assets in the full schema.
- feature_names_in_ndarray of shape (
n_features_in_,) Asset names, defined when the input names are all strings.
Methods
fit(X[, y])Fit an ordering from a distance snapshot.
Get metadata routing of this object.
get_params([deep])Get parameters for this estimator.
set_params(**params)Set the parameters of this estimator.
Notes
Symmetry and zero diagonal checks use an absolute tolerance of 1e-5. Symmetry uses no relative tolerance. Negative distances down to -1e-8 are accepted and clipped to zero. Accepted asymmetry is averaged, and diagonal entries are set to zero. The input matrix is not modified.
- abstractmethod fit(X, y=None)[source]#
Fit an ordering from a distance snapshot.
- Parameters:
- Xarray-like of shape (n_assets, n_assets)
Distance matrix. NaN diagonal entries mark non-investable assets.
- yIgnored
Not used, present for API consistency by convention.
- Returns:
- selfBaseSeriation
Fitted estimator.
- 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_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.