r""" Fits the Smooth Strongly Convex Nearest Brenier Potential [58] to the source data :code:`Xs` to the target data :code:`Xt`, with the partition given by the (optional) labels :code:`ys`. Wrapper for :code:`ot.mapping.nearest_brenier_potential_fit`. .. warning::
(self, Xs=None, ys=None, Xt=None, yt=None)
| 2675 | self.fit_Xs, self.fit_ys, self.fit_Xt = None, None, None |
| 2676 | |
| 2677 | def fit(self, Xs=None, ys=None, Xt=None, yt=None): |
| 2678 | r""" |
| 2679 | Fits the Smooth Strongly Convex Nearest Brenier Potential [58] to the source data :code:`Xs` to the target data |
| 2680 | :code:`Xt`, with the partition given by the (optional) labels :code:`ys`. |
| 2681 | |
| 2682 | Wrapper for :code:`ot.mapping.nearest_brenier_potential_fit`. |
| 2683 | |
| 2684 | .. warning:: This function requires the CVXPY library |
| 2685 | .. warning:: Accepts any backend but will convert to Numpy then back to the backend. |
| 2686 | |
| 2687 | Parameters |
| 2688 | ---------- |
| 2689 | Xs : array-like (n, d) |
| 2690 | source points used to compute the optimal values phi and G |
| 2691 | ys : array-like (n,), optional |
| 2692 | classes of the reference points, defaults to a single class |
| 2693 | Xt : array-like (n, d) |
| 2694 | values of the gradients at the reference points X |
| 2695 | yt : optional |
| 2696 | ignored. |
| 2697 | |
| 2698 | Returns |
| 2699 | ------- |
| 2700 | self : object |
| 2701 | Returns self. |
| 2702 | |
| 2703 | References |
| 2704 | ---------- |
| 2705 | |
| 2706 | .. [58] François-Pierre Paty, Alexandre d’Aspremont, and Marco Cuturi. Regularity as regularization: |
| 2707 | Smooth and strongly convex brenier potentials in optimal transport. In International Conference |
| 2708 | on Artificial Intelligence and Statistics, pages 1222–1232. PMLR, 2020. |
| 2709 | |
| 2710 | See Also |
| 2711 | -------- |
| 2712 | ot.mapping.nearest_brenier_potential_fit : Fitting the SSNB on source and target data |
| 2713 | |
| 2714 | """ |
| 2715 | self.fit_Xs, self.fit_ys, self.fit_Xt = Xs, ys, Xt |
| 2716 | returned = nearest_brenier_potential_fit( |
| 2717 | Xs, |
| 2718 | Xt, |
| 2719 | X_classes=ys, |
| 2720 | strongly_convex_constant=self.strongly_convex_constant, |
| 2721 | gradient_lipschitz_constant=self.gradient_lipschitz_constant, |
| 2722 | its=self.its, |
| 2723 | log=self.log, |
| 2724 | ) |
| 2725 | |
| 2726 | if self.log: |
| 2727 | self.phi, self.G, self.fit_log = returned |
| 2728 | else: |
| 2729 | self.phi, self.G = returned |
| 2730 | |
| 2731 | return self |
| 2732 | |
| 2733 | def transform(self, Xs, ys=None): |
| 2734 | r""" |
nothing calls this directly
no test coverage detected