skfolio.factor_exposure.BaseFactorExposure#
- class skfolio.factor_exposure.BaseFactorExposure(*, family)[source]#
Base class for factor exposure estimators.
A factor exposure estimator takes an
AssetPaneland 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
BaseAssetPanelTransformerprotocol:Batch-only estimators implement only
fit_transform.Stateless estimators declare
stateless=Trueand implement onlyfit_transform. The base class addspartial_fit_transformby delegating tofit_transform.Online estimators implement both
fit_transformandpartial_fit_transform.fit_transformstarts from a clean state andpartial_fit_transformcontinues 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 of this object.
get_params([deep])Get parameters for this estimator.
set_params(**params)Set the parameters of this estimator.
See also
BaseAssetPanelTransformerShared transformer contract.
BaseDescriptorComputes 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
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.