<a id="skfolio-seriation-baseseriation"></a>

# skfolio.seriation.BaseSeriation

<a id="skfolio.seriation.BaseSeriation"></a>

### *class* skfolio.seriation.BaseSeriation

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`](#skfolio.seriation.BaseSeriation.fit)(X[, y])            | Fit an ordering from a distance snapshot.   |
|-------------------------------------------------------------------------|---------------------------------------------|
| [`get_metadata_routing`](#skfolio.seriation.BaseSeriation.get_metadata_routing)() | Get metadata routing of this object.        |
| [`get_params`](#skfolio.seriation.BaseSeriation.get_params)([deep])     | Get parameters for this estimator.          |
| [`set_params`](#skfolio.seriation.BaseSeriation.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.

<a id="skfolio.seriation.BaseSeriation.fit"></a>

#### *abstractmethod* fit(X, y=None)

Fit an ordering from a distance snapshot.

* **Parameters:**
  **X** *array-like of shape (n_assets, n_assets)*
  : Distance matrix. NaN diagonal entries mark non-investable assets.

  **y** *Ignored*
  : Not used, present for API consistency by convention.
* **Returns:**
  **self** *BaseSeriation*
  : Fitted estimator.

<a id="skfolio.seriation.BaseSeriation.get_metadata_routing"></a>

#### get_metadata_routing()

Get metadata routing of this object.

Please check [User Guide](https://skfolio.org/user_guide/metadata_routing.html.md#metadata-routing) on how the routing
mechanism works.

* **Returns:**
  **routing** *MetadataRequest*
  : A `MetadataRequest` encapsulating
    routing information.

<a id="skfolio.seriation.BaseSeriation.get_params"></a>

#### get_params(deep=True)

Get parameters for this estimator.

* **Parameters:**
  **deep** *bool, default=True*
  : If True, will return the parameters for this estimator and
    contained subobjects that are estimators.
* **Returns:**
  **params** *dict*
  : Parameter names mapped to their values.

<a id="skfolio.seriation.BaseSeriation.set_params"></a>

#### 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:**
  **\*\*params** *dict*
  : Estimator parameters.
* **Returns:**
  **self** *estimator instance*
  : Estimator instance.

