SkWDRO - Tractable Wasserstein Distributionally Robust Optimization

Workflow Test Workflow Style Workflow Doc
PyPI - Python Version

Welcome to SkWDRO’s doc#

skwdro is a Python package that offers WDRO versions for a large range of estimators, either by extending scikit-learn estimators or by providing a wrapper for pytorch modules.

Here is a quick reading order that we advise:

        flowchart TD
   A(((Getting started))):::important
   A -->|"Dive in quickly"| B["User guide"]:::important
   A -->|"If you are a bit new to DRO"| C["What is WDRO?"]:::normal
   C --> D["Why SkWDRO?"]:::important
   D --> B

   B -->|"Implement your own problem"| F["Pytorch interface"]:::important
   F --> G["Pytorch examples"]:::normal

   B -->|"For pre-implemented examples"| H["Sklearn interfaces"]:::normal
   H --> I["Sklearn examples"]:::normal

   G --> J["API"]:::important
   I --> J

   G -->|"In depth explanations"| K>"Samplers"]
   K --> L>"Cost functionals"]

   %% Styles
   classDef important color:#EE8888,fill:#f9f2d0,stroke:#e6b800,stroke-width:2px,color:black,rx:10px,ry:10px;
   classDef normal color:#888888,fill:#f2f2f2,stroke:#999999,stroke-width:1.5px,color:black,stroke-dasharray:3 3,rx:20px,ry:20px;

   %% Hyperlinks
   click A "quick_start.html"
   click B "user_guide.html"
   click C "wdro.html"
   click D "why_skwdro.html"
   click F "pytorch.html"
   click G "examples/Custom/index.html"
   click H "sklearn.html"
   click I "examples/Builtin/index.html"
   click J "api_deepdive/submodules.html"
   click K "tutos/samplers.html"
   click L "tutos/costs.html"
    

Getting started#

Install it now!#
$ pip3 install skwdro

See the getting-started guide to see how to install the package and get to learn its basic usage. Then you can take a look at some of the theory that goes behind the duality result we use to make Sinkhorn-WDRO tractable.

SkWDRO main formula

If you are performing “Empirical Risk Minimization”, and wish to robustify it, we can do it through the following transformation:

\[\frac{1}{N}\sum_{i=1}^N L(\xi_i) ~ \longmapsto ~ \min_{\lambda\ge 0}\rho\lambda+\varepsilon\frac{1}{N}\sum_{i=1}^N \log\mathbb{E}_{\zeta\sim\nu_{\xi_i}}\left[\frac{L(\zeta)-\lambda c(\xi_i, \zeta)}{\varepsilon}\right]\]

This transformation introduces computational difficulties, so let us handle it for you!

User Guide#

Quick hitchhiker’s guide to the interfaces available to guide you through the process of robustification in “simple” cases.

In depth guide to the PyTorch customization functions#

Learn more about the way you can robustify your own model with SkWDRO and how to specify it to make it compatible with the library.

Next#

Cite#

skwdro is the result of a research project. It is licensed under BSD 3-Clause. You are free to use it and if you do so, please cite:

Cite as follows:#
 @article{JMLR:v27:24-1840,
   author  = {Vincent Florian and Wa{\"i}ss Azizian and Franck Iutzeler and J{\'e}r{\^o}me Malick},
   title   = {skwdro: a library for Wasserstein distributionally robust machine learning},
   journal = {Journal of Machine Learning Research},
   year    = {2026},
   volume  = {27},
   number  = {8},
   pages   = {1--7},
   url     = {http://jmlr.org/papers/v27/24-1840.html}
 }