MOT DRO

class dro.linear_model.mot_dro.MOTDRO(input_dim, model_type='svm', fit_intercept=True, solver='MOSEK')

Bases: BaseLinearDRO

Optimal Transport DRO with Conditional Moment Constraints.

Implements DRO with composite transportation cost:

\[c\big(((X_1,Y_1),w), ((X_2,Y_2),\hat{w})\big) = \theta_1 w \cdot d((X_1,Y_1),(X_2,Y_2)) + \theta_2 (\phi(w) - \phi(\hat{w}))^+\]

where \(\phi(\cdot)\) is the KL divergence.

Variables:
  • theta1 (float) – Wasserstein distance scaling factor (\(\theta_1 \geq 0\))

  • theta2 (float) – KL divergence penalty coefficient (\(\theta_2 \geq 0\))

  • eps (float) – Robustness radius for OT ambiguity set (\(\epsilon \geq 0\))

  • p (Union[float, str]) – Norm order for feature perturbation. Valid values: 2 (L2), ‘inf’ (L_inf)

Parameters:
  • input_dim (int)

  • model_type (str)

  • fit_intercept (bool)

  • solver (str)

Initialize MOT-DRO with restricted model types.

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

  • model_type (str) –

    Base model type. Defaults to ‘svm’. Supported:

    • 'svm': Support Vector Machine (hinge loss)

    • 'lad': Least Absolute Deviation (L1 loss)

  • fit_intercept (bool) – Whether to learn intercept term. Set False for pre-centered data. Defaults to True.

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

Raises:

MOTDROError

  • If model_type in [‘ols’, ‘logistic’]

  • If input_dim < 1

Default Parameters:

  • theta1: 1.0 (minimum Wasserstein scaling)

  • square: 2.0 (quadratic regularization strength)

Example:
>>> model = MOTDRO(input_dim=5, model_type='svm')
>>> model.theta1 = 1.5  
>>> model.square = 1.0  
update(config)

Update MOTDRO model configuration with coupled parameters.

Parameters:

config (Dict[str, Any]) –

Dictionary containing parameters to update. Valid keys:

  • theta1 (float > 1):

    Wasserstein distance scaling factor. Updates trigger: \(\theta_2 = \frac{1}{1 - 1/\theta_1}\)

  • theta2 (float > 1):

    KL divergence penalty coefficient. Updates trigger: \(\theta_1 = \frac{1}{1 - 1/\theta_2}\)

  • eps (float ≥ 0):

    Robustness radius for OT ambiguity set

  • p (float ≥1 or ‘inf’):

    Perturbation norm order (1 ≤ p ≤ ∞)

Raises:

MOTDROError

  • If theta1 ≤ 1 or theta2 ≤ 1

  • If theta1/theta2 relationship becomes invalid

  • If eps < 0 or non-numeric

  • If p < 1 (when numeric) or not ‘inf’

  • If parameter types are incorrect

Return type:

None

Parameter Coupling:
  • \(\theta_1\) and \(\theta_2\) are related through:

    \(\theta_1 = \frac{1}{1 - 1/\theta_2}\)

  • Updating one automatically adjusts the other

Example:
>>> model.update({
...     'theta1': 2.5,       
...     'p': 'inf',          
...     'eps': 0.3           
... })
fit(X, y)

Fit the MMD-DRO model to the data.

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,)

Return type:

Dict[str, Any]