<a id="skfolio-descriptor-basedescriptor"></a>

# skfolio.descriptor.BaseDescriptor

<a id="skfolio.descriptor.BaseDescriptor"></a>

### *class* skfolio.descriptor.BaseDescriptor

Base class for all descriptor transformers.

A descriptor takes an [`AssetPanel`](https://skfolio.org/generated/skfolio.containers.AssetPanel.html.md#skfolio.containers.AssetPanel) and returns one raw
descriptor value per observation and asset, usually with shape
`(n_observations, n_assets)`. Descriptors are the inputs used by factor exposure
estimators such as [`FixedWeightedFactor`](https://skfolio.org/generated/skfolio.factor_exposure.FixedWeightedFactor.html.md#skfolio.factor_exposure.FixedWeightedFactor).

Descriptors follow the [`BaseAssetPanelTransformer`](https://skfolio.org/generated/skfolio.base.BaseAssetPanelTransformer.html.md#skfolio.base.BaseAssetPanelTransformer)
protocol:

- Batch-only descriptors implement only `fit_transform`.
- Stateless descriptors declare `stateless=True` and implement only
  `fit_transform`. The base class adds `partial_fit_transform` by
  delegating to `fit_transform`.
- Online descriptors implement both `fit_transform` and
  `partial_fit_transform`. `fit_transform` starts from a clean state;
  `partial_fit_transform` continues from the current state.

Examples include direct field access ([`Passthrough`](https://skfolio.org/generated/skfolio.descriptor.Passthrough.html.md#skfolio.descriptor.Passthrough)), point-in-time
ratios ([`BookToPrice`](https://skfolio.org/generated/skfolio.descriptor.BookToPrice.html.md#skfolio.descriptor.BookToPrice)), and history-dependent descriptors
([`EWMomentum`](https://skfolio.org/generated/skfolio.descriptor.EWMomentum.html.md#skfolio.descriptor.EWMomentum)).

### Methods

| [`fit_transform`](#skfolio.descriptor.BaseDescriptor.fit_transform)(X[, y])   | Fit the transformer if needed and return transformed values.   |
|--------------------------------------------------------------------------|----------------------------------------------------------------|
| [`get_metadata_routing`](#skfolio.descriptor.BaseDescriptor.get_metadata_routing)()  | Get metadata routing of this object.                           |
| [`get_params`](#skfolio.descriptor.BaseDescriptor.get_params)([deep])      | Get parameters for this estimator.                             |
| [`set_params`](#skfolio.descriptor.BaseDescriptor.set_params)(\*\*params)  | Set the parameters of this estimator.                          |

#### SEE ALSO
[`BaseAssetPanelTransformer`](https://skfolio.org/generated/skfolio.base.BaseAssetPanelTransformer.html.md#skfolio.base.BaseAssetPanelTransformer)
: Shared transformer contract.

[`BaseFactorExposure`](https://skfolio.org/generated/skfolio.factor_exposure.BaseFactorExposure.html.md#skfolio.factor_exposure.BaseFactorExposure)
: Combines descriptors into factor exposures.

<a id="skfolio.descriptor.BaseDescriptor.fit_transform"></a>

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

Fit the transformer if needed and return transformed values.

* **Parameters:**
  **X** *AssetPanel*
  : Input panel data.

  **y** *None*
  : Ignored. Present for API consistency.

  **\*\*fit_params** *dict*
  : Additional fit parameters. Metadata routing may pass these parameters to
    sub-estimators when applicable.
* **Returns:**
  **values** *ndarray of shape (n_observations, n_assets) or (n_observations, n_assets, n_components)*
  : Transformed values.

<a id="skfolio.descriptor.BaseDescriptor.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.descriptor.BaseDescriptor.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.descriptor.BaseDescriptor.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.

