MOT DRO¶
Transport configuration¶
Configure the ambiguity radius, feature norm, and transport exponent with
model.update({...}):
eps: non-negative OT ambiguity radius.p: feature perturbation norm order, one of1,2, or'inf'(default:2).square: transport exponent, either1or2(default:2).
Targets remain fixed, and the feature transport cost is
||x - x_hat||_p ** square. For example, p=2, square=2 selects squared
Euclidean transport; p=2, square=1 selects Euclidean transport.
Unsupported norms or exponents raise MOTDROError.
from dro.linear_model.mot_dro import MOTDRO
model = MOTDRO(input_dim=2, model_type='lad')
model.update({'eps': 0.1, 'p': 2, 'square': 2})
- class dro.linear_model.mot_dro.MOTDRO(input_dim, model_type='svm', fit_intercept=True, solver='CLARABEL')¶
Bases:
BaseLinearDROOptimal 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:
- Parameters:
Feature transport keeps targets fixed and uses the cost
||X_1 - X_2||_p ** square. The norm order and transport exponent are independent parameters.- Variables:
- Parameters:
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 ‘CLARABEL’.
- Raises:
MOTDROError –
If
model_typein [‘ols’, ‘logistic’]If
input_dim< 1
Default Parameters:
theta1: 1.0 (minimum Wasserstein scaling)p: 2 (Euclidean feature perturbation norm)square: 2 (squared feature transport cost)
- Example:
>>> model = MOTDRO(input_dim=5, model_type='svm') >>> model.update({'theta1': 1.5, 'eps': 0.1, 'p': 2, 'square': 1})
- update(config)¶
Update MOTDRO model configuration with coupled parameters.
- Parameters:
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(1, 2, or ‘inf’):Feature perturbation norm order. Defaults to 2.
square(1 or 2):Transport exponent, independent of the norm order. Defaults to 2.
- Raises:
MOTDROError –
If
theta1≤ 1 ortheta2≤ 1If
theta1/theta2relationship becomes invalidIf
eps< 0 or non-numericIf
pis not 1, 2, or ‘inf’If
squareis not 1 or 2If parameter types are incorrect
- Return type:
- 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', ... 'square': 2, ... 'eps': 0.3 ... })
- fit(X, y)¶
Fit the MOT-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]