<a id="skfolio-uncertainty-set-orthogonalcovarianceuncertaintyset"></a>

# skfolio.uncertainty_set.OrthogonalCovarianceUncertaintySet

<a id="skfolio.uncertainty_set.OrthogonalCovarianceUncertaintySet"></a>

### *class* skfolio.uncertainty_set.OrthogonalCovarianceUncertaintySet(radius=1.0, cs_weighting=INVERSE_IDIO_VARIANCE)

Covariance uncertainty set estimator for directions outside the factor span.

This estimator builds a compact covariance uncertainty set for robust portfolio
optimization [[1]](#read94a27047e-1) [[2]](#read94a27047e-2) [[3]](#read94a27047e-3). The robust penalty assigns additional covariance uncertainty to
portfolio directions that are in the subspace orthogonal to the factor-model
loading matrix, under the selected cross-sectional weighting metric.

The base covariance is assumed to have the factor structure

$$
\Sigma = B F B^\top + D
$$

where $B$ is the loading matrix, $F$ is the factor covariance matrix
and $D$ is the idiosyncratic covariance matrix.

Under this uncertainty set, the worst-case variance for a portfolio with weights
$w$ is

$$
\sup_{\Sigma \in U} w^\top \Sigma\, w
=
w^\top \hat{\Sigma} w
+
\kappa
\min_z
\lVert C w - Q z \rVert_2^2.
$$

Here, $Q$ is an orthonormal basis of the weighted factor span
$\operatorname{col}(W^{1/2} B)$ and $C = W^{-1/2}$.

The expression is the compact form of the quadratic penalty

$$
\kappa C^\top (I - Q Q^\top) C.
$$

This structured form avoids the lifted SDP formulation used for fully generic
covariance uncertainty sets and avoids materializing the dense matrix [[4]](#read94a27047e-4)
$C^\top (I - Q Q^\top) C$.

If the factor model uses basket-neutral constraints, the loading matrix is first
reduced to its effective full-rank basis before the orthogonal subspace is computed.

* **Parameters:**
  **radius** *float, default=1.0*
  : Penalty radius $\kappa$. Controls the magnitude of the orthogonal
    covariance penalty. Must be non-negative.

  **cs_weighting** *CSWeighting, default=CSWeighting.INVERSE_IDIO_VARIANCE*
  : Cross-sectional weighting used to define the orthogonality metric.
* **Attributes:**
  **uncertainty_set_** *CompactCovarianceUncertaintySet*
  : Fitted solver-ready uncertainty set containing the radius, diagonal metric
    square root and basis.

### Methods

| [`fit`](#skfolio.uncertainty_set.OrthogonalCovarianceUncertaintySet.fit)(X[, y, return_distribution])                   | Fit the orthogonal covariance uncertainty set.                                           |
|-----------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------|
| [`get_metadata_routing`](#skfolio.uncertainty_set.OrthogonalCovarianceUncertaintySet.get_metadata_routing)()                             | Get metadata routing of this object.                                                     |
| [`get_params`](#skfolio.uncertainty_set.OrthogonalCovarianceUncertaintySet.get_params)([deep])                                 | Get parameters for this estimator.                                                       |
| [`partial_fit`](#skfolio.uncertainty_set.OrthogonalCovarianceUncertaintySet.partial_fit)(X[, y, return_distribution])           | Update the orthogonal covariance uncertainty set.                                        |
| [`set_fit_request`](#skfolio.uncertainty_set.OrthogonalCovarianceUncertaintySet.set_fit_request)(\*[, return_distribution])         | Configure whether metadata should be requested to be passed to the `fit` method.         |
| [`set_params`](#skfolio.uncertainty_set.OrthogonalCovarianceUncertaintySet.set_params)(\*\*params)                             | Set the parameters of this estimator.                                                    |
| [`set_partial_fit_request`](#skfolio.uncertainty_set.OrthogonalCovarianceUncertaintySet.set_partial_fit_request)(\*[, return_distribution]) | Configure whether metadata should be requested to be passed to the `partial_fit` method. |

### Notes

This estimator requires a factor model in the return distribution. When used inside
[`MeanRisk`](https://skfolio.org/generated/skfolio.optimization.MeanRisk.html.md#skfolio.optimization.MeanRisk), the `return_distribution` metadata is
passed automatically by `fit` and `partial_fit`. Covariance uncertainty is applied
when `risk_measure=RiskMeasure.VARIANCE` or when `max_variance` is set.

### References

* <a id='read94a27047e-1'>**[1]**</a> “Robustness properties of mean-variance portfolios”, Optimization: A Journal of Mathematical Programming and Operations Research, Schöttle & Werner (2009).
* <a id='read94a27047e-2'>**[2]**</a> “Portfolio Optimization: Theory and Application”, Chapter 14, Daniel P. Palomar (2025)
* <a id='read94a27047e-3'>**[3]**</a> “Robust Portfolio Selection Problems”, Mathematics of Operations Research, Goldfarb and Iyengar (2003).
* <a id='read94a27047e-4'>**[4]**</a> “Robust Convex Optimization”, Mathematics of Operations Research, Ben-Tal and Nemirovski (1998).

<a id="skfolio.uncertainty_set.OrthogonalCovarianceUncertaintySet.fit"></a>

#### fit(X, y=None, \*, return_distribution=None, \*\*fit_params)

Fit the orthogonal covariance uncertainty set.

* **Parameters:**
  **X** *array-like of shape (n_observations, n_assets)*
  : Price returns of the assets.

  **y** *array-like of shape (n_observations, n_factors), optional*
  : Price returns of factors. The default is `None`.

  **return_distribution** *ReturnDistribution, optional*
  : The fitted return distribution from the prior estimator.
    Passed internally by [`MeanRisk`](https://skfolio.org/generated/skfolio.optimization.MeanRisk.html.md#skfolio.optimization.MeanRisk). Must contain a
    `factor_model` with `loading_matrix` and `idio_covariance`.

  **\*\*fit_params** *dict*
  : Additional parameters (unused).
* **Returns:**
  **self** *OrthogonalCovarianceUncertaintySet*
  : Fitted estimator.

<a id="skfolio.uncertainty_set.OrthogonalCovarianceUncertaintySet.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.uncertainty_set.OrthogonalCovarianceUncertaintySet.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.uncertainty_set.OrthogonalCovarianceUncertaintySet.partial_fit"></a>

#### partial_fit(X, y=None, \*, return_distribution=None, \*\*fit_params)

Update the orthogonal covariance uncertainty set.

* **Parameters:**
  **X** *array-like of shape (n_observations, n_assets)*
  : Price returns of the assets.

  **y** *array-like of shape (n_observations, n_factors), optional*
  : Price returns of factors. The default is `None`.

  **return_distribution** *ReturnDistribution, optional*
  : The fitted return distribution from the prior estimator.
    Passed internally by [`MeanRisk`](https://skfolio.org/generated/skfolio.optimization.MeanRisk.html.md#skfolio.optimization.MeanRisk). Must contain a
    `factor_model` with `loading_matrix` and `idio_covariance`.

  **\*\*fit_params** *dict*
  : Additional parameters (unused).
* **Returns:**
  **self** *OrthogonalCovarianceUncertaintySet*
  : Updated estimator.

<a id="skfolio.uncertainty_set.OrthogonalCovarianceUncertaintySet.set_fit_request"></a>

#### set_fit_request(\*, return_distribution='$UNCHANGED$')

Configure whether metadata should be requested to be passed to the `fit` method.

Note that this method is only relevant when this estimator is used as a
sub-estimator within a meta-estimator and metadata routing is enabled
with `enable_metadata_routing=True` (see `sklearn.set_config`).
Please check the [User Guide](https://skfolio.org/user_guide/metadata_routing.html.md#metadata-routing) on how the routing
mechanism works.

The options for each parameter are:

- `True`: metadata is requested, and passed to `fit` if provided. The request is ignored if metadata is not provided.
- `False`: metadata is not requested and the meta-estimator will not pass it to `fit`.
- `None`: metadata is not requested, and the meta-estimator will raise an error if the user provides it.
- `str`: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (`sklearn.utils.metadata_routing.UNCHANGED`) retains the
existing request. This allows you to change the request for some
parameters and not others.

#### Versionadded
Added in version 1.3.

* **Parameters:**
  **return_distribution** *str, True, False, or None,                     default=sklearn.utils.metadata_routing.UNCHANGED*
  : Metadata routing for `return_distribution` parameter in `fit`.
* **Returns:**
  **self** *object*
  : The updated object.

<a id="skfolio.uncertainty_set.OrthogonalCovarianceUncertaintySet.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.

<a id="skfolio.uncertainty_set.OrthogonalCovarianceUncertaintySet.set_partial_fit_request"></a>

#### set_partial_fit_request(\*, return_distribution='$UNCHANGED$')

Configure whether metadata should be requested to be passed to the `partial_fit` method.

Note that this method is only relevant when this estimator is used as a
sub-estimator within a meta-estimator and metadata routing is enabled
with `enable_metadata_routing=True` (see `sklearn.set_config`).
Please check the [User Guide](https://skfolio.org/user_guide/metadata_routing.html.md#metadata-routing) on how the routing
mechanism works.

The options for each parameter are:

- `True`: metadata is requested, and passed to `partial_fit` if provided. The request is ignored if metadata is not provided.
- `False`: metadata is not requested and the meta-estimator will not pass it to `partial_fit`.
- `None`: metadata is not requested, and the meta-estimator will raise an error if the user provides it.
- `str`: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (`sklearn.utils.metadata_routing.UNCHANGED`) retains the
existing request. This allows you to change the request for some
parameters and not others.

#### Versionadded
Added in version 1.3.

* **Parameters:**
  **return_distribution** *str, True, False, or None,                     default=sklearn.utils.metadata_routing.UNCHANGED*
  : Metadata routing for `return_distribution` parameter in `partial_fit`.
* **Returns:**
  **self** *object*
  : The updated object.

