<a id="skfolio-factor-exposure-basefactorexposure"></a>

# skfolio.factor_exposure.BaseFactorExposure

<a id="skfolio.factor_exposure.BaseFactorExposure"></a>

### *class* skfolio.factor_exposure.BaseFactorExposure(\*, family)

Base class for factor exposure estimators.

A factor exposure estimator takes an [`AssetPanel`](https://skfolio.org/generated/skfolio.containers.AssetPanel.html.md#skfolio.containers.AssetPanel) and
returns asset exposures to one or more factors. Single-factor estimators return
values with shape `(n_observations, n_assets)`. Multi-factor estimators return
values with shape `(n_observations, n_assets, n_factors)`.

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

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

* **Parameters:**
  **family** *str*
  : The factor family this exposure belongs to (e.g., “market”, “style”, “industry”,
    “country”). Factor families group related factors for basket-neutral
    constraints, neutralization, attribution and reporting.

### Methods

| [`fit_transform`](#skfolio.factor_exposure.BaseFactorExposure.fit_transform)(X[, y])   | Fit the transformer if needed and return transformed values.   |
|--------------------------------------------------------------------------|----------------------------------------------------------------|
| [`get_metadata_routing`](#skfolio.factor_exposure.BaseFactorExposure.get_metadata_routing)()  | Get metadata routing of this object.                           |
| [`get_params`](#skfolio.factor_exposure.BaseFactorExposure.get_params)([deep])      | Get parameters for this estimator.                             |
| [`set_params`](#skfolio.factor_exposure.BaseFactorExposure.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.

[`BaseDescriptor`](https://skfolio.org/generated/skfolio.descriptor.BaseDescriptor.html.md#skfolio.descriptor.BaseDescriptor)
: Computes raw descriptor values.

<a id="skfolio.factor_exposure.BaseFactorExposure.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.factor_exposure.BaseFactorExposure.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.factor_exposure.BaseFactorExposure.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.factor_exposure.BaseFactorExposure.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.

