skfolio.moments.BaseVariance#
- class skfolio.moments.BaseVariance(assume_centered=False)[source]#
Base class for all variance estimators in
skfolio.Variance estimators estimate the diagonal elements of a covariance matrix, assuming zero correlation between assets. This is appropriate when:
Estimating idiosyncratic (specific) risk in factor models, where residual returns are uncorrelated by construction
Working with orthogonalized or uncorrelated return series
The full covariance structure is not needed or is constructed separately
- Parameters:
- assume_centeredbool, default=False
If False (default), the data are mean-centered before computing the variance. This is the standard behavior when working with raw returns where the mean is not guaranteed to be zero. If True, the estimator assumes the input data are already centered. Use this when you know the returns have zero mean, such as pre-demeaned data or regression residuals.
- Attributes:
- variance_ndarray of shape (n_assets,)
Estimated variance vector \((\\sigma^2_1, ..., \\sigma^2_n)\).
- location_ndarray of shape (n_assets,)
Estimated location, i.e. the estimated mean. When
assume_centered=True, this is zero. Whenassume_centered=False, this is the sample mean.- n_features_in_int
Number of assets seen during
fit.- feature_names_in_ndarray of shape (
n_features_in_,) Names of assets seen during
fit. Defined only whenXhas asset names that are all strings.
Methods
Get metadata routing of this object.
get_params([deep])Get parameters for this estimator.
set_params(**params)Set the parameters of this estimator.
fit
Notes
All estimators should specify all the parameters that can be set at the class level in their
__init__as explicit keyword arguments (no*argsor**kwargs).- 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.