Holistic Robust DRO

class dro.src.linear_model.hr_dro.HR_DRO_LR(input_dim, model_type='svm', fit_intercept=True, solver='MOSEK', r=1.0, alpha=1.0, epsilon=0.5, epsilon_prime=1.0)

Bases: BaseLinearDRO

Holistic Robust DRO Linear Regression (HR_DRO_LR) model.

This model supports HR DRO with additional robustness constraints for linear regression and binary classification. (Theorem 7)

Reference: <https://arxiv.org/abs/2207.09560>

Initialize advanced DRO model with dual robustness parameters.

Parameters:
  • input_dim (int) – Number of input features. Must be ≥ 1.

  • model_type (str) – Base model type. Defaults to ‘svm’.

  • fit_intercept (bool) – Whether to fit intercept term. Defaults to True.

  • solver (str) – Optimization solver. Defaults to ‘MOSEK’.

  • r (float) – Ambiguity set curvature parameter. Must satisfy r ≥ 0. Defaults to 1.0.

  • alpha (float) – Risk level parameter. Must satisfy 0 < alpha ≤ 1. Defaults to 1.0.

  • epsilon (float) – Wasserstein radius for distribution shifts. Must be ≥ 0. Defaults to 0.5.

  • epsilon_prime (float) – Robustness budget for moment constraints. Must be ≥ 0. Defaults to 1.0.

Raises:

ValueError

  • If any parameter violates numerical constraints (r < 0, alpha ∉ (0,1], etc.)

  • If model_type is not in allowed set

  • If input_dim < 1

Example:
>>> model = HR_DRO_LR(
...     input_dim=5, 
...     model_type='logistic',
...     r=0.5, 
...     epsilon=0.3,
...     epsilon_prime=0.8
... )
>>> print(model.r, model.epsilon_prime)
0.5 0.8
update(config={})

Dynamically update robustness parameters of the Advanced DRO model.

Modifies multi-level ambiguity set parameters while preserving existing model state. Changes require manual re-fitting to take effect.

Parameters:

config (Dict[str, Any]) –

Dictionary containing parameter updates. Supported keys:

  • r: Curvature parameter for ambiguity set (must be ≥ 0)

  • alpha: Risk level for CVaR-like constraints (must satisfy 0 < alpha ≤ 1)

  • epsilon: Wasserstein radius for distribution shifts (must be ≥ 0)

  • epsilon_prime: Moment constraint robustness budget (must be ≥ 0)

Raises:

ValueError

  • If any parameter violates numerical constraints

  • If invalid parameter types are provided

Return type:

None

Parameter Relationships:

  • Larger epsilon allows more distribution shift

  • Higher r creates more conservative ambiguity set geometries

  • epsilon_prime controls second-order moment robustness

Example:
>>> model = HR_DRO_LR(input_dim=5, r=1.0, epsilon=0.5)
>>> model.update({"r": 0.8, "epsilon": 0.6})  # Valid update
>>> model.update({"alpha": 1.5})  # Invalid alpha
Traceback (most recent call last):
    ...
ValueError: alpha must be in (0, 1], got 1.5

Note

  • Empty config dictionary will preserve current parameters

  • Partial updates are allowed (only modify specified parameters)

  • Always validate parameters before optimization phase

fit(X, Y)

Solve the dual-ambiguity DRO problem via convex optimization.

Parameters:
  • X (numpy.ndarray) – Training feature matrix of shape (n_samples, n_features). Must satisfy n_features == self.input_dim.

  • Y (numpy.ndarray) –

    Target values of shape (n_samples,). Format requirements:

    • Classification: ±1 labels

    • Regression: Continuous values

Returns:

Dictionary containing trained parameters:

  • theta: Weight vector of shape (n_features,)

  • b: Intercept term (if fit_intercept=True)

Return type:

Dict[str, Any]

Raises:
  • HRDROError

    • If optimization fails due to solver errors

    • If problem becomes infeasible with current parameters

  • ValueError

    • If X.shape[1] != self.input_dim

    • If X.shape[0] != Y.shape[0]

    • If parameters violate r ≥ 0, epsilon ≥ 0, etc.

Optimization Formulation:
\[\min_{\theta,b} \sup_{Q \in \mathcal{Q}} \mathbb{E}_Q[\ell(\theta,b;X,Y)]\]

where the ambiguity set \(\mathcal{Q}\) satisfies:

\[W(P,Q) \leq \epsilon \]
\[\text{CVaR}_\alpha(\ell) \leq \tau + r\epsilon' \]
\[\mathbb{E}_Q[\phi(X)] \leq \mathbb{E}_P[\phi(X)] + \epsilon'\]
  • \(W(P,Q)\) = Wasserstein distance between distributions

  • \(r\) = curvature parameter from self.r

  • \(\phi(\cdot)\) = moment constraint function

Example:
>>> model = HR_DRO_LR(input_dim=3, r=0.5, epsilon=0.4)
>>> X_train = np.random.randn(100, 3)
>>> y_train = np.sign(np.random.randn(100))  # Binary labels
>>> params = model.fit(X_train, y_train)
>>> print(params["theta"].shape)  # (3,)
>>> print("dual_vars" in params)  # True

Note

  • Solution time grows cubically with n_samples

  • Set epsilon=0 to disable Wasserstein constraints