MCPcopy Create free account
hub / github.com/PythonOT/POT / regularization_path

Function regularization_path

ot/regpath.py:836–912  ·  view source on GitHub ↗

r"""This function provides all the solutions of the regularization path \ of the l2-UOT problem :ref:`[41] `. The problem to optimize is the Lasso reformulation of the l2-penalized UOT: .. math:: \min_t \gamma \mathbf{c}^T \mathbf{t} + 0.5 *

(
    a: np.array, b: np.array, C: np.array, reg=1e-4, semi_relaxed=False, itmax=50000
)

Source from the content-addressed store, hash-verified

834
835
836def regularization_path(
837 a: np.array, b: np.array, C: np.array, reg=1e-4, semi_relaxed=False, itmax=50000
838):
839 r"""This function provides all the solutions of the regularization path \
840 of the l2-UOT problem :ref:`[41] <references-regpath>`.
841
842 The problem to optimize is the Lasso reformulation of the l2-penalized UOT:
843
844 .. math::
845 \min_t \gamma \mathbf{c}^T \mathbf{t}
846 + 0.5 * \|{H} \mathbf{t} - \mathbf{y}\|_2^2
847
848 s.t.
849 \mathbf{t} \geq 0
850
851 where :
852
853 - :math:`\mathbf{c}` is the flattened version of the cost matrix \
854 :math:`{C}`
855 - :math:`\gamma = 1/\lambda` is the l2-regularization coefficient
856 - :math:`\mathbf{y}` is the concatenation of vectors :math:`\mathbf{a}` \
857 and :math:`\mathbf{b}`, defined as \
858 :math:`\mathbf{y}^T = [\mathbf{a}^T \mathbf{b}^T]`
859 - :math:`{H}` is a design matrix, see :ref:`[41] <references-regpath>` \
860 for the design of :math:`{H}`. The matrix product :math:`H\mathbf{t}` \
861 computes both the source marginal and the target marginals.
862 - :math:`\mathbf{t}` is the flattened version of the transport matrix
863
864 For the semi-relaxed problem, it optimizes the Lasso reformulation of the
865 l2-penalized UOT:
866
867 .. math::
868
869 \min_t \gamma \mathbf{c}^T \mathbf{t}
870 + 0.5 * \|H_r \mathbf{t} - \mathbf{a}\|_2^2
871
872 s.t.
873 H_c \mathbf{t} = \mathbf{b}
874
875 \mathbf{t} \geq 0
876
877
878 Parameters
879 ----------
880 a : np.ndarray (dim_a,)
881 Histogram of dimension dim_a
882 b : np.ndarray (dim_b,)
883 Histogram of dimension dim_b
884 C : np.ndarray, shape (dim_a, dim_b)
885 Cost matrix
886 reg: float (optional)
887 l2-regularization coefficient
888 semi_relaxed : bool (optional)
889 Give the semi-relaxed path if True
890 itmax: int (optional)
891 Maximum number of iteration
892
893 Returns

Callers

nothing calls this directly

Calls 2

semi_relaxed_pathFunction · 0.85
fully_relaxed_pathFunction · 0.85

Tested by

no test coverage detected