Risk covariance estimators API

SampleCovariance

class
skportfolio.riskreturn._risk_estimators.SampleCovariance(returns_data=False, frequency=252)
Bases
skportfolio.riskreturn._risk_estimators.BaseRiskEstimator sklearn.base.TransformerMixin sklearn.base.BaseEstimator

The standard sample covariance estimator, based on historical data.

Methods
  • fit_transform(X, y, **fit_params) (X_new : ndarray array of shape (n_samples, n_features_new)) Fit to data, then transform it.
  • get_params(deep) (params : dict) Get parameters for this estimator.
  • set_params(**params) (self : estimator instance) Set the parameters of this estimator.
method
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.

method
set_params(**params)

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as :class:~sklearn.pipeline.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.

method
fit_transform(X, y=None, **fit_params)

Fit to data, then transform it.

Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.

Parameters
  • X (array-like of shape (n_samples, n_features)) Input samples.
  • y (array-like of shape (n_samples,) or (n_samples, n_outputs), default=None) Target values (None for unsupervised transformations).
  • **fit_params (dict) Additional fit parameters.
Returns (X_new : ndarray array of shape (n_samples, n_features_new))

Transformed array.

CovarianceExp

class
skportfolio.riskreturn._risk_estimators.CovarianceExp(returns_data=False, frequency=252, span=60)
Bases
skportfolio.riskreturn._risk_estimators.BaseRiskEstimator sklearn.base.TransformerMixin sklearn.base.BaseEstimator

Estimator of covariance based on exponential weighted average of returns

Methods
  • fit_transform(X, y, **fit_params) (X_new : ndarray array of shape (n_samples, n_features_new)) Fit to data, then transform it.
  • get_params(deep) (params : dict) Get parameters for this estimator.
  • set_params(**params) (self : estimator instance) Set the parameters of this estimator.
method
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.

method
set_params(**params)

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as :class:~sklearn.pipeline.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.

method
fit_transform(X, y=None, **fit_params)

Fit to data, then transform it.

Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.

Parameters
  • X (array-like of shape (n_samples, n_features)) Input samples.
  • y (array-like of shape (n_samples,) or (n_samples, n_outputs), default=None) Target values (None for unsupervised transformations).
  • **fit_params (dict) Additional fit parameters.
Returns (X_new : ndarray array of shape (n_samples, n_features_new))

Transformed array.

CovarianceGlasso

class
skportfolio.riskreturn._risk_estimators.CovarianceGlasso(returns_data=False, frequency=252)
Bases
skportfolio.riskreturn._risk_estimators.BaseRiskEstimator sklearn.base.TransformerMixin sklearn.base.BaseEstimator

Estimator of covariance based on GLASSO algorithm

Methods
  • fit_transform(X, y, **fit_params) (X_new : ndarray array of shape (n_samples, n_features_new)) Fit to data, then transform it.
  • get_params(deep) (params : dict) Get parameters for this estimator.
  • set_params(**params) (self : estimator instance) Set the parameters of this estimator.
method
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.

method
set_params(**params)

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as :class:~sklearn.pipeline.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.

method
fit_transform(X, y=None, **fit_params)

Fit to data, then transform it.

Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.

Parameters
  • X (array-like of shape (n_samples, n_features)) Input samples.
  • y (array-like of shape (n_samples,) or (n_samples, n_outputs), default=None) Target values (None for unsupervised transformations).
  • **fit_params (dict) Additional fit parameters.
Returns (X_new : ndarray array of shape (n_samples, n_features_new))

Transformed array.

CovarianceHierarchicalFilterAverage

class
skportfolio.riskreturn._risk_estimators.CovarianceHierarchicalFilterAverage(returns_data=False, frequency=252)
Bases
skportfolio.riskreturn._risk_estimators.BaseRiskEstimator sklearn.base.TransformerMixin sklearn.base.BaseEstimator

Estimator of covariance based on hierarchical filtering approach.

Methods
  • fit_transform(X, y, **fit_params) (X_new : ndarray array of shape (n_samples, n_features_new)) Fit to data, then transform it.
  • get_params(deep) (params : dict) Get parameters for this estimator.
  • set_params(**params) (self : estimator instance) Set the parameters of this estimator.
method
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.

method
set_params(**params)

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as :class:~sklearn.pipeline.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.

method
fit_transform(X, y=None, **fit_params)

Fit to data, then transform it.

Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.

Parameters
  • X (array-like of shape (n_samples, n_features)) Input samples.
  • y (array-like of shape (n_samples,) or (n_samples, n_outputs), default=None) Target values (None for unsupervised transformations).
  • **fit_params (dict) Additional fit parameters.
Returns (X_new : ndarray array of shape (n_samples, n_features_new))

Transformed array.

CovarianceHierarchicalFilterComplete

class
skportfolio.riskreturn._risk_estimators.CovarianceHierarchicalFilterComplete(returns_data=False, frequency=252)
Bases
skportfolio.riskreturn._risk_estimators.BaseRiskEstimator sklearn.base.TransformerMixin sklearn.base.BaseEstimator

Estimator of covariance based on hierarchical filtering approach.

Methods
  • fit_transform(X, y, **fit_params) (X_new : ndarray array of shape (n_samples, n_features_new)) Fit to data, then transform it.
  • get_params(deep) (params : dict) Get parameters for this estimator.
  • set_params(**params) (self : estimator instance) Set the parameters of this estimator.
method
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.

method
set_params(**params)

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as :class:~sklearn.pipeline.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.

method
fit_transform(X, y=None, **fit_params)

Fit to data, then transform it.

Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.

Parameters
  • X (array-like of shape (n_samples, n_features)) Input samples.
  • y (array-like of shape (n_samples,) or (n_samples, n_outputs), default=None) Target values (None for unsupervised transformations).
  • **fit_params (dict) Additional fit parameters.
Returns (X_new : ndarray array of shape (n_samples, n_features_new))

Transformed array.

CovarianceHierarchicalFilterSingle

class
skportfolio.riskreturn._risk_estimators.CovarianceHierarchicalFilterSingle(returns_data=False, frequency=252)
Bases
skportfolio.riskreturn._risk_estimators.BaseRiskEstimator sklearn.base.TransformerMixin sklearn.base.BaseEstimator

Estimator of covariance based on hierarchical filtering approach.

Methods
  • fit_transform(X, y, **fit_params) (X_new : ndarray array of shape (n_samples, n_features_new)) Fit to data, then transform it.
  • get_params(deep) (params : dict) Get parameters for this estimator.
  • set_params(**params) (self : estimator instance) Set the parameters of this estimator.
method
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.

method
set_params(**params)

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as :class:~sklearn.pipeline.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.

method
fit_transform(X, y=None, **fit_params)

Fit to data, then transform it.

Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.

Parameters
  • X (array-like of shape (n_samples, n_features)) Input samples.
  • y (array-like of shape (n_samples,) or (n_samples, n_outputs), default=None) Target values (None for unsupervised transformations).
  • **fit_params (dict) Additional fit parameters.
Returns (X_new : ndarray array of shape (n_samples, n_features_new))

Transformed array.

CovarianceLedoitWolf

class
skportfolio.riskreturn._risk_estimators.CovarianceLedoitWolf(returns_data=False, frequency=252, shrinkage_target='constant_variance')
Bases
skportfolio.riskreturn._risk_estimators.BaseRiskEstimator sklearn.base.TransformerMixin sklearn.base.BaseEstimator

Estimator of covariance based on the Ledoit-Wolf shrinkage

Methods
  • fit_transform(X, y, **fit_params) (X_new : ndarray array of shape (n_samples, n_features_new)) Fit to data, then transform it.
  • get_params(deep) (params : dict) Get parameters for this estimator.
  • set_params(**params) (self : estimator instance) Set the parameters of this estimator.
method
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.

method
set_params(**params)

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as :class:~sklearn.pipeline.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.

method
fit_transform(X, y=None, **fit_params)

Fit to data, then transform it.

Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.

Parameters
  • X (array-like of shape (n_samples, n_features)) Input samples.
  • y (array-like of shape (n_samples,) or (n_samples, n_outputs), default=None) Target values (None for unsupervised transformations).
  • **fit_params (dict) Additional fit parameters.
Returns (X_new : ndarray array of shape (n_samples, n_features_new))

Transformed array.

CovarianceRMT

class
skportfolio.riskreturn._risk_estimators.CovarianceRMT(returns_data=False, frequency=252)
Bases
skportfolio.riskreturn._risk_estimators.BaseRiskEstimator sklearn.base.TransformerMixin sklearn.base.BaseEstimator

Estimator of covariance based on Random Matrix Theory

Methods
  • fit_transform(X, y, **fit_params) (X_new : ndarray array of shape (n_samples, n_features_new)) Fit to data, then transform it.
  • get_params(deep) (params : dict) Get parameters for this estimator.
  • set_params(**params) (self : estimator instance) Set the parameters of this estimator.
method
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.

method
set_params(**params)

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as :class:~sklearn.pipeline.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.

method
fit_transform(X, y=None, **fit_params)

Fit to data, then transform it.

Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.

Parameters
  • X (array-like of shape (n_samples, n_features)) Input samples.
  • y (array-like of shape (n_samples,) or (n_samples, n_outputs), default=None) Target values (None for unsupervised transformations).
  • **fit_params (dict) Additional fit parameters.
Returns (X_new : ndarray array of shape (n_samples, n_features_new))

Transformed array.

SemiCovariance

class
skportfolio.riskreturn._risk_estimators.SemiCovariance(returns_data=False, frequency=252)
Bases
skportfolio.riskreturn._risk_estimators.BaseRiskEstimator sklearn.base.TransformerMixin sklearn.base.BaseEstimator

The semicovariance, a.k.a. the covariance matrix estimated from only the positive returns.

Methods
  • fit_transform(X, y, **fit_params) (X_new : ndarray array of shape (n_samples, n_features_new)) Fit to data, then transform it.
  • get_params(deep) (params : dict) Get parameters for this estimator.
  • set_params(**params) (self : estimator instance) Set the parameters of this estimator.
method
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.

method
set_params(**params)

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as :class:~sklearn.pipeline.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.

method
fit_transform(X, y=None, **fit_params)

Fit to data, then transform it.

Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.

Parameters
  • X (array-like of shape (n_samples, n_features)) Input samples.
  • y (array-like of shape (n_samples,) or (n_samples, n_outputs), default=None) Target values (None for unsupervised transformations).
  • **fit_params (dict) Additional fit parameters.
Returns (X_new : ndarray array of shape (n_samples, n_features_new))

Transformed array.