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

Method transform

ot/da.py:2733–2787  ·  view source on GitHub ↗

r""" Computes the images of the new source samples :code:`Xs` of classes :code:`ys` by the fitted Smooth Strongly Convex Nearest Brenier Potentials (SSNB) :ref:`[58]`. The output is the images of two SSNB optimal maps, called 'lower' and 'upper' potentials (from :ref:`[59]`,

(self, Xs, ys=None)

Source from the content-addressed store, hash-verified

2731 return self
2732
2733 def transform(self, Xs, ys=None):
2734 r"""
2735 Computes the images of the new source samples :code:`Xs` of classes :code:`ys` by the fitted
2736 Smooth Strongly Convex Nearest Brenier Potentials (SSNB) :ref:`[58]`. The output is the images of two SSNB optimal
2737 maps, called 'lower' and 'upper' potentials (from :ref:`[59]`, Theorem 3.14).
2738
2739 Wrapper for :code:`nearest_brenier_potential_predict_bounds`.
2740
2741 .. warning:: This function requires the CVXPY library
2742 .. warning:: Accepts any backend but will convert to Numpy then back to the backend.
2743
2744 Parameters
2745 ----------
2746 Xs : array-like (m, d)
2747 input source points
2748 ys : : array_like (m,), optional
2749 classes of the input source points, defaults to a single class
2750
2751 Returns
2752 -------
2753 G_lu : array-like (2, m, d)
2754 gradients of the lower and upper bounding potentials at Y (images of the source inputs)
2755
2756 References
2757 ----------
2758
2759 .. [58] François-Pierre Paty, Alexandre d’Aspremont, and Marco Cuturi. Regularity as regularization:
2760 Smooth and strongly convex brenier potentials in optimal transport. In International Conference
2761 on Artificial Intelligence and Statistics, pages 1222–1232. PMLR, 2020.
2762
2763 .. [59] Adrien B Taylor. Convex interpolation and performance estimation of first-order methods for
2764 convex optimization. PhD thesis, Catholic University of Louvain, Louvain-la-Neuve, Belgium,
2765 2017.
2766
2767 See Also
2768 --------
2769 ot.mapping.nearest_brenier_potential_predict_bounds : Predicting SSNB images on new source data
2770
2771 """
2772 returned = nearest_brenier_potential_predict_bounds(
2773 self.fit_Xs,
2774 self.phi,
2775 self.G,
2776 Xs,
2777 X_classes=self.fit_ys,
2778 Y_classes=ys,
2779 strongly_convex_constant=self.strongly_convex_constant,
2780 gradient_lipschitz_constant=self.gradient_lipschitz_constant,
2781 log=self.log,
2782 )
2783 if self.log:
2784 _, G_lu, self.predict_log = returned
2785 else:
2786 _, G_lu = returned
2787 return G_lu

Callers

nothing calls this directly

Tested by

no test coverage detected