skfolio.factor_exposure.BaseFactorExposure#

class skfolio.factor_exposure.BaseFactorExposure(*, family)[source]#

Base class for factor exposure estimators.

A factor exposure estimator takes an 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 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:
familystr

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(X[, y])

Fit the transformer if needed and return transformed values.

get_metadata_routing()

Get metadata routing of this object.

get_params([deep])

Get parameters for this estimator.

set_params(**params)

Set the parameters of this estimator.

See also

BaseAssetPanelTransformer

Shared transformer contract.

BaseDescriptor

Computes raw descriptor values.

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

Fit the transformer if needed and return transformed values.

Parameters:
XAssetPanel

Input panel data.

yNone

Ignored. Present for API consistency.

**fit_paramsdict

Additional fit parameters. Metadata routing may pass these parameters to sub-estimators when applicable.

Returns:
valuesndarray of shape (n_observations, n_assets) or (n_observations, n_assets, n_components)

Transformed values.

get_metadata_routing()#

Get metadata routing of this object.

Please check User Guide on how the routing mechanism works.

Returns:
routingMetadataRequest

A MetadataRequest encapsulating 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.