with \(\mathbf{S^s}_{i,j}, \mathbf{S^t}_{i,j}\) denoting source and target similarity
matrices and \(T(\cdot)\) being a barycentric mapping.
The algorithm used for solving the problem is the conditional gradient algorithm as proposed in
[5].
Parameters:
a (array-like (ns,)) – samples weights in the source domain
b (array-like (nt,)) – samples weights in the target domain
xs (array-like (ns,d)) – samples in the source domain
xt (array-like (nt,d)) – samples in the target domain
M (array-like (ns,nt)) – loss matrix
sim (string, optional) – Type of similarity (‘knn’ or ‘gauss’) used to construct the Laplacian.
sim_param (int or float, optional) – Parameter (number of the nearest neighbors for sim=’knn’
or bandwidth for sim=’gauss’) used to compute the Laplacian.
reg (string) – Type of Laplacian regularization
eta (float) – Regularization term for Laplacian regularization
alpha (float) – Regularization term for source domain’s importance in regularization
numItermax (int, optional) – Max number of iterations
\(\Omega_e\) is the entropic regularization term
\(\Omega_e(\gamma)=\sum_{i,j} \gamma_{i,j}\log(\gamma_{i,j})\)
\(\Omega_g\) is the group lasso regularization term
\(\Omega_g(\gamma)=\sum_{i,c} \|\gamma_{i,\mathcal{I}_c}\|^2\)
where \(\mathcal{I}_c\) are the index of samples from class
c in the source domain.
\(\mathbf{a}\) and \(\mathbf{b}\) are source and target weights (sum to 1)
The algorithm used for solving the problem is the generalized conditional
gradient as proposed in [5, 7].
Parameters:
a (array-like (ns,)) – samples weights in the source domain
labels_a (array-like (ns,)) – labels of samples in the source domain
b (array-like (nt,)) – samples in the target domain
M (array-like (ns,nt)) – loss matrix
reg (float) – Regularization term for entropic regularization >0
eta (float, optional) – Regularization term for group lasso regularization >0
numItermax (int, optional) – Max number of iterations
numInnerItermax (int, optional) – Max number of iterations (inner sinkhorn solver)
\(\Omega_e\) is the entropic regularization term \(\Omega_e
(\gamma)=\sum_{i,j} \gamma_{i,j}\log(\gamma_{i,j})\)
\(\Omega_g\) is the group lasso regularization term
\(\Omega_g(\gamma)=\sum_{i,c} \|\gamma_{i,\mathcal{I}_c}\|^{1/2}_1\)
where \(\mathcal{I}_c\) are the index of samples from class c
in the source domain.
\(\mathbf{a}\) and \(\mathbf{b}\) are source and target weights (sum to 1)
The algorithm used for solving the problem is the generalized conditional
gradient as proposed in [5, 7].
Parameters:
a (array-like (ns,)) – samples weights in the source domain
labels_a (array-like (ns,)) – labels of samples in the source domain
b (array-like (nt,)) – samples weights in the target domain
M (array-like (ns,nt)) – loss matrix
reg (float) – Regularization term for entropic regularization >0
eta (float, optional) – Regularization term for group lasso regularization >0
numItermax (int, optional) – Max number of iterations
numInnerItermax (int, optional) – Max number of iterations (inner sinkhorn solver)
All estimators should specify all the parameters that can be set
at the class level in their __init__ as explicit keyword
arguments (no *args or **kwargs).
The fit method should:
estimate a cost matrix and store it in a cost_ attribute
estimate a coupling matrix and store it in a coupling_ attribute
estimate distributions from source and target data and store them in
mu_s and mu_t attributes
store Xs and Xt in attributes to be used later on in transform and
inverse_transform methods
transform method should always get as input a Xs parameter
inverse_transform method should always get as input a Xt parameter
transform_labels method should always get as input a ys parameter
inverse_transform_labels method should always get as input a yt parameter
Build a coupling matrix from source and target sets of samples
\((\mathbf{X_s}, \mathbf{y_s})\) and \((\mathbf{X_t}, \mathbf{y_t})\)
and transports source samples \(\mathbf{X_s}\) onto target ones \(\mathbf{X_t}\)
Parameters:
Xs (array-like, shape (n_source_samples, n_features)) – The training input samples.
ys (array-like, shape (n_source_samples,)) – The class labels for training samples
Xt (array-like, shape (n_target_samples, n_features)) – The training input samples.
yt (array-like, shape (n_target_samples,)) –
The class labels. If some target samples are unlabelled, fill the
\(\mathbf{y_t}\)’s elements with -1.
Warning: Note that, due to this convention -1 cannot be used as a
class label
Domain Adaptation OT method based on Earth Mover’s Distance with Laplacian regularization
Parameters:
reg_type (string optional (default='pos')) – Type of the regularization term: ‘pos’ and ‘disp’ for
regularization term defined in [2] and
[6], respectively.
reg_src (float, optional (default=0.5)) – Source relative importance in regularization
metric (string, optional (default="sqeuclidean")) – The ground metric for the Wasserstein problem
norm (string, optional (default=None)) – If given, normalize the ground metric to avoid numerical errors that
can occur with large metric values.
similarity (string, optional (default="knn")) – The similarity to use either knn or gaussian
similarity_param (int or float, optional (default=None)) – Parameter for the similarity: number of nearest neighbors or bandwidth
if similarity=”knn” or “gaussian”, respectively. If None is provided,
it is set to 3 or the average pairwise squared Euclidean distance, respectively.
max_iter (int, optional (default=100)) – Max number of BCD iterations
tol (float, optional (default=1e-5)) – Stop threshold on relative loss decrease (>0)
max_inner_iter (int, optional (default=10)) – Max number of iterations (inner CG solver)
log (int, optional (default=False)) – Controls the logs of the optimization algorithm
distribution_estimation (callable, optional (defaults to the uniform)) – The kind of distribution estimation to employ
out_of_sample_map (string, optional (default="ferradans")) – The kind of out of sample mapping to apply to transport samples
from a domain into another one. Currently the only possible option is
“ferradans” which uses the method proposed in [6].
Domain Adaptation OT method based on Earth Mover’s Distance
Parameters:
metric (string, optional (default="sqeuclidean")) – The ground metric for the Wasserstein problem
norm (string, optional (default=None)) – If given, normalize the ground metric to avoid numerical errors that
can occur with large metric values.
log (int, optional (default=False)) – Controls the logs of the optimization algorithm
distribution_estimation (callable, optional (defaults to the uniform)) – The kind of distribution estimation to employ
out_of_sample_map (string, optional (default="ferradans")) – The kind of out of sample mapping to apply to transport samples
from a domain into another one. Currently the only possible option is
“ferradans” which uses the method proposed in [6].
limit_max (float, optional (default=10)) – Controls the semi supervised mode. Transport between labeled source
and target samples of different classes will exhibit an infinite cost
(10 times the maximum value of the cost matrix)
max_iter (int, optional (default=100000)) – The maximum number of iterations before stopping the optimization
algorithm if it has not converged.
max_iter (int, float, optional (default=10)) – The minimum number of iteration before stopping the optimization
algorithm if it has not converged
tol (float, optional (default=10e-9)) – Stop threshold on error (inner sinkhorn solver) (>0)
verbose (bool, optional (default=False)) – Controls the verbosity of the optimization algorithm
log (bool, optional (default=False)) – Controls the logs of the optimization algorithm
metric (string, optional (default="sqeuclidean")) – The ground metric for the Wasserstein problem
norm (string, optional (default=None)) – If given, normalize the ground metric to avoid numerical errors that
can occur with large metric values.
distribution_estimation (callable, optional (defaults to the uniform)) – The kind of distribution estimation to employ
out_of_sample_map (string, optional (default="ferradans")) – The kind of out of sample mapping to apply to transport samples
from a domain into another one. Currently the only possible option is
“ferradans” which uses the method proposed in [6].
OT Gaussian Gromov-Wasserstein linear operator between empirical distributions
The function estimates the optimal linear operator that aligns the two
empirical distributions optimally wrt the Gromov-Wasserstein distance. This is equivalent to estimating the closed
form mapping between two Gaussian distributions \(\mathcal{N}(\mu_s,\Sigma_s)\)
and \(\mathcal{N}(\mu_t,\Sigma_t)\) as proposed in
[57].
where the matrix \(\mathbf{A}\) and the vector \(\mathbf{b}\) are
defined in [57].
Parameters:
sign_eigs (array-like (n_features), str, optional) – sign of the eigenvalues of the mapping matrix, by default all signs will
be positive. If ‘skewness’ is provided, the sign of the eigenvalues is
selected as the product of the sign of the skewness of the projected data.
OT linear operator between empirical distributions
The function estimates the optimal linear operator that aligns the two
empirical distributions. This is equivalent to estimating the closed
form mapping between two Gaussian distributions \(\mathcal{N}(\mu_s,\Sigma_s)\)
and \(\mathcal{N}(\mu_t,\Sigma_t)\) as proposed in
[14] and discussed in remark 2.29 in
[15].
Builds an optimal coupling and estimates the associated mapping
from source and target sets of samples
\((\mathbf{X_s}, \mathbf{y_s})\) and \((\mathbf{X_t}, \mathbf{y_t})\)
Parameters:
Xs (array-like, shape (n_source_samples, n_features)) – The training input samples.
ys (array-like, shape (n_source_samples,)) – The class labels
Xt (array-like, shape (n_target_samples, n_features)) – The training input samples.
yt (array-like, shape (n_target_samples,)) –
The class labels. If some target samples are unlabelled, fill the
\(\mathbf{y_t}\)’s elements with -1.
Warning: Note that, due to this convention -1 cannot be used as a
class label
Smooth Strongly Convex Nearest Brenier Potentials (SSNB) is a method from [58] that computes
an l-strongly convex potential \(\varphi\) with an L-Lipschitz gradient such that
\(\nabla \varphi \# \mu \approx \nu\). This regularity can be enforced only on the components of a partition
of the ambient space (encoded by point classes), which is a relaxation compared to imposing global regularity.
SSNBs approach the target measure by solving the optimisation problem:
where \(\mathcal{F}\) is the space functions that are on every set \(E_k\) l-strongly convex
with an L-Lipschitz gradient, given \((E_k)_{k \in [K]}\) a partition of the ambient source space.
The problem is solved on “fitting” source and target data via a convex Quadratically Constrained Quadratic Program,
yielding the values phi and the gradients G at at the source points.
The images of “new” source samples are then found by solving a (simpler) Quadratically Constrained Linear Program
at each point, using the fitting “parameters” phi and G. We provide two possible images, which
correspond to “lower” and “upper potentials” ([59], Theorem 3.14). Each of these two images are optimal
solutions of the SSNB problem, and can be used in practice.
Warning
This function requires the CVXPY library
Warning
Accepts any backend but will convert to Numpy then back to the backend.
Parameters:
strongly_convex_constant (float, optional) – constant for the strong convexity of the input potential phi, defaults to 0.6
gradient_lipschitz_constant (float, optional) – constant for the Lipschitz property of the input gradient G, defaults to 1.4
its (int, optional) – number of iterations, defaults to 100
Fits the Smooth Strongly Convex Nearest Brenier Potential [58] to the source data Xs to the target data
Xt, with the partition given by the (optional) labels ys.
Wrapper for ot.mapping.nearest_brenier_potential_fit.
Warning
This function requires the CVXPY library
Warning
Accepts any backend but will convert to Numpy then back to the backend.
Parameters:
Xs (array-like (n, d)) – source points used to compute the optimal values phi and G
ys (array-like (n,), optional) – classes of the reference points, defaults to a single class
Xt (array-like (n, d)) – values of the gradients at the reference points X
Computes the images of the new source samples Xs of classes ys by the fitted
Smooth Strongly Convex Nearest Brenier Potentials (SSNB) [58]. The output is the images of two SSNB optimal
maps, called ‘lower’ and ‘upper’ potentials (from [59], Theorem 3.14).
Wrapper for nearest_brenier_potential_predict_bounds.
Warning
This function requires the CVXPY library
Warning
Accepts any backend but will convert to Numpy then back to the backend.
Parameters:
Xs (array-like (m, d)) – input source points
ys (: array_like (m,), optional) – classes of the input source points, defaults to a single class
Returns:
G_lu – gradients of the lower and upper bounding potentials at Y (images of the source inputs)
reg_cl (float, optional (default=0.1)) – Class regularization parameter
max_iter (int, float, optional (default=10)) – The minimum number of iteration before stopping the optimization
algorithm if it has not converged
max_inner_iter (int, float, optional (default=200)) – The number of iteration in the inner loop
tol (float, optional (default=10e-9)) – Stop threshold on error (inner sinkhorn solver) (>0)
verbose (bool, optional (default=False)) – Controls the verbosity of the optimization algorithm
log (bool, optional (default=False)) – Controls the logs of the optimization algorithm
metric (string, optional (default="sqeuclidean")) – The ground metric for the Wasserstein problem
norm (string, optional (default=None)) – If given, normalize the ground metric to avoid numerical errors that
can occur with large metric values.
distribution_estimation (callable, optional (defaults to the uniform)) – The kind of distribution estimation to employ
out_of_sample_map (string, optional (default="ferradans")) – The kind of out of sample mapping to apply to transport samples
from a domain into another one. Currently the only possible option is
“ferradans” which uses the method proposed in [6].
limit_max (float, optional (default=10)) – Controls the semi supervised mode. Transport between labeled source
and target samples of different classes will exhibit an infinite cost
(10 times the maximum value of the cost matrix)
reg_cl (float, optional (default=0.1)) – Class regularization parameter
max_iter (int, float, optional (default=10)) – The minimum number of iteration before stopping the optimization
algorithm if it has not converged
max_inner_iter (int, float, optional (default=200)) – The number of iteration in the inner loop
log (bool, optional (default=False)) – Controls the logs of the optimization algorithm
tol (float, optional (default=10e-9)) – Stop threshold on error (inner sinkhorn solver) (>0)
verbose (bool, optional (default=False)) – Controls the verbosity of the optimization algorithm
metric (string, optional (default="sqeuclidean")) – The ground metric for the Wasserstein problem
norm (string, optional (default=None)) – If given, normalize the ground metric to avoid numerical errors that
can occur with large metric values.
distribution_estimation (callable, optional (defaults to the uniform)) – The kind of distribution estimation to employ
out_of_sample_map (string, optional (default="ferradans")) – The kind of out of sample mapping to apply to transport samples
from a domain into another one. Currently the only possible option is
“ferradans” which uses the method proposed in [6].
limit_max (float, optional (default=np.inf)) – Controls the semi supervised mode. Transport between labeled source
and target samples of different classes will exhibit a cost defined by
limit_max.
max_iter (int, float, optional (default=1000)) – The minimum number of iteration before stopping the optimization
algorithm if it has not converged
tol (float, optional (default=10e-9)) – The precision required to stop the optimization algorithm.
verbose (bool, optional (default=False)) – Controls the verbosity of the optimization algorithm
log (int, optional (default=False)) – Controls the logs of the optimization algorithm
metric (string, optional (default="sqeuclidean")) – The ground metric for the Wasserstein problem
norm (string, optional (default=None)) – If given, normalize the ground metric to avoid numerical errors that
can occur with large metric values. Accepted values are ‘median’,
‘max’, ‘log’ and ‘loglog’.
distribution_estimation (callable, optional (defaults to the uniform)) – The kind of distribution estimation to employ
out_of_sample_map (string, optional (default="continuous")) – The kind of out of sample mapping to apply to transport samples
from a domain into another one. Currently the only possible option is
“ferradans” which uses the nearest neighbor method proposed in [6] while “continuous” use the out of sample
method from [66] and [19].
limit_max (float, optional (default=np.inf)) – Controls the semi supervised mode. Transport between labeled source
and target samples of different classes will exhibit an cost defined
by this variable
reg_m (float, optional (default=0.1)) – Mass regularization parameter
method (str) – method used for the solver either ‘sinkhorn’, ‘sinkhorn_stabilized’ or
‘sinkhorn_epsilon_scaling’, see those function for specific parameters
max_iter (int, float, optional (default=10)) – The minimum number of iteration before stopping the optimization
algorithm if it has not converged
tol (float, optional (default=10e-9)) – Stop threshold on error (inner sinkhorn solver) (>0)
verbose (bool, optional (default=False)) – Controls the verbosity of the optimization algorithm
log (bool, optional (default=False)) – Controls the logs of the optimization algorithm
metric (string, optional (default="sqeuclidean")) – The ground metric for the Wasserstein problem
norm (string, optional (default=None)) – If given, normalize the ground metric to avoid numerical errors that
can occur with large metric values.
distribution_estimation (callable, optional (defaults to the uniform)) – The kind of distribution estimation to employ
out_of_sample_map (string, optional (default="ferradans")) – The kind of out of sample mapping to apply to transport samples
from a domain into another one. Currently the only possible option is
“ferradans” which uses the method proposed in [6].
limit_max (float, optional (default=10)) – Controls the semi supervised mode. Transport between labeled source
and target samples of different classes will exhibit an infinite cost
(10 times the maximum value of the cost matrix)
All estimators should specify all the parameters that can be set
at the class level in their __init__ as explicit keyword
arguments (no *args or **kwargs).
The fit method should:
estimate a cost matrix and store it in a cost_ attribute
estimate a coupling matrix and store it in a coupling_ attribute
estimate distributions from source and target data and store them in
mu_s and mu_t attributes
store Xs and Xt in attributes to be used later on in transform and
inverse_transform methods
transform method should always get as input a Xs parameter
inverse_transform method should always get as input a Xt parameter
transform_labels method should always get as input a ys parameter
inverse_transform_labels method should always get as input a yt parameter
Build a coupling matrix from source and target sets of samples
\((\mathbf{X_s}, \mathbf{y_s})\) and \((\mathbf{X_t}, \mathbf{y_t})\)
and transports source samples \(\mathbf{X_s}\) onto target ones \(\mathbf{X_t}\)
Parameters:
Xs (array-like, shape (n_source_samples, n_features)) – The training input samples.
ys (array-like, shape (n_source_samples,)) – The class labels for training samples
Xt (array-like, shape (n_target_samples, n_features)) – The training input samples.
yt (array-like, shape (n_target_samples,)) –
The class labels. If some target samples are unlabelled, fill the
\(\mathbf{y_t}\)’s elements with -1.
Warning: Note that, due to this convention -1 cannot be used as a
class label
Domain Adaptation OT method based on Earth Mover’s Distance with Laplacian regularization
Parameters:
reg_type (string optional (default='pos')) – Type of the regularization term: ‘pos’ and ‘disp’ for
regularization term defined in [2] and
[6], respectively.
reg_src (float, optional (default=0.5)) – Source relative importance in regularization
metric (string, optional (default="sqeuclidean")) – The ground metric for the Wasserstein problem
norm (string, optional (default=None)) – If given, normalize the ground metric to avoid numerical errors that
can occur with large metric values.
similarity (string, optional (default="knn")) – The similarity to use either knn or gaussian
similarity_param (int or float, optional (default=None)) – Parameter for the similarity: number of nearest neighbors or bandwidth
if similarity=”knn” or “gaussian”, respectively. If None is provided,
it is set to 3 or the average pairwise squared Euclidean distance, respectively.
max_iter (int, optional (default=100)) – Max number of BCD iterations
tol (float, optional (default=1e-5)) – Stop threshold on relative loss decrease (>0)
max_inner_iter (int, optional (default=10)) – Max number of iterations (inner CG solver)
log (int, optional (default=False)) – Controls the logs of the optimization algorithm
distribution_estimation (callable, optional (defaults to the uniform)) – The kind of distribution estimation to employ
out_of_sample_map (string, optional (default="ferradans")) – The kind of out of sample mapping to apply to transport samples
from a domain into another one. Currently the only possible option is
“ferradans” which uses the method proposed in [6].
Domain Adaptation OT method based on Earth Mover’s Distance
Parameters:
metric (string, optional (default="sqeuclidean")) – The ground metric for the Wasserstein problem
norm (string, optional (default=None)) – If given, normalize the ground metric to avoid numerical errors that
can occur with large metric values.
log (int, optional (default=False)) – Controls the logs of the optimization algorithm
distribution_estimation (callable, optional (defaults to the uniform)) – The kind of distribution estimation to employ
out_of_sample_map (string, optional (default="ferradans")) – The kind of out of sample mapping to apply to transport samples
from a domain into another one. Currently the only possible option is
“ferradans” which uses the method proposed in [6].
limit_max (float, optional (default=10)) – Controls the semi supervised mode. Transport between labeled source
and target samples of different classes will exhibit an infinite cost
(10 times the maximum value of the cost matrix)
max_iter (int, optional (default=100000)) – The maximum number of iterations before stopping the optimization
algorithm if it has not converged.
max_iter (int, float, optional (default=10)) – The minimum number of iteration before stopping the optimization
algorithm if it has not converged
tol (float, optional (default=10e-9)) – Stop threshold on error (inner sinkhorn solver) (>0)
verbose (bool, optional (default=False)) – Controls the verbosity of the optimization algorithm
log (bool, optional (default=False)) – Controls the logs of the optimization algorithm
metric (string, optional (default="sqeuclidean")) – The ground metric for the Wasserstein problem
norm (string, optional (default=None)) – If given, normalize the ground metric to avoid numerical errors that
can occur with large metric values.
distribution_estimation (callable, optional (defaults to the uniform)) – The kind of distribution estimation to employ
out_of_sample_map (string, optional (default="ferradans")) – The kind of out of sample mapping to apply to transport samples
from a domain into another one. Currently the only possible option is
“ferradans” which uses the method proposed in [6].
OT Gaussian Gromov-Wasserstein linear operator between empirical distributions
The function estimates the optimal linear operator that aligns the two
empirical distributions optimally wrt the Gromov-Wasserstein distance. This is equivalent to estimating the closed
form mapping between two Gaussian distributions \(\mathcal{N}(\mu_s,\Sigma_s)\)
and \(\mathcal{N}(\mu_t,\Sigma_t)\) as proposed in
[57].
where the matrix \(\mathbf{A}\) and the vector \(\mathbf{b}\) are
defined in [57].
Parameters:
sign_eigs (array-like (n_features), str, optional) – sign of the eigenvalues of the mapping matrix, by default all signs will
be positive. If ‘skewness’ is provided, the sign of the eigenvalues is
selected as the product of the sign of the skewness of the projected data.
OT linear operator between empirical distributions
The function estimates the optimal linear operator that aligns the two
empirical distributions. This is equivalent to estimating the closed
form mapping between two Gaussian distributions \(\mathcal{N}(\mu_s,\Sigma_s)\)
and \(\mathcal{N}(\mu_t,\Sigma_t)\) as proposed in
[14] and discussed in remark 2.29 in
[15].
Builds an optimal coupling and estimates the associated mapping
from source and target sets of samples
\((\mathbf{X_s}, \mathbf{y_s})\) and \((\mathbf{X_t}, \mathbf{y_t})\)
Parameters:
Xs (array-like, shape (n_source_samples, n_features)) – The training input samples.
ys (array-like, shape (n_source_samples,)) – The class labels
Xt (array-like, shape (n_target_samples, n_features)) – The training input samples.
yt (array-like, shape (n_target_samples,)) –
The class labels. If some target samples are unlabelled, fill the
\(\mathbf{y_t}\)’s elements with -1.
Warning: Note that, due to this convention -1 cannot be used as a
class label
Smooth Strongly Convex Nearest Brenier Potentials (SSNB) is a method from [58] that computes
an l-strongly convex potential \(\varphi\) with an L-Lipschitz gradient such that
\(\nabla \varphi \# \mu \approx \nu\). This regularity can be enforced only on the components of a partition
of the ambient space (encoded by point classes), which is a relaxation compared to imposing global regularity.
SSNBs approach the target measure by solving the optimisation problem:
where \(\mathcal{F}\) is the space functions that are on every set \(E_k\) l-strongly convex
with an L-Lipschitz gradient, given \((E_k)_{k \in [K]}\) a partition of the ambient source space.
The problem is solved on “fitting” source and target data via a convex Quadratically Constrained Quadratic Program,
yielding the values phi and the gradients G at at the source points.
The images of “new” source samples are then found by solving a (simpler) Quadratically Constrained Linear Program
at each point, using the fitting “parameters” phi and G. We provide two possible images, which
correspond to “lower” and “upper potentials” ([59], Theorem 3.14). Each of these two images are optimal
solutions of the SSNB problem, and can be used in practice.
Warning
This function requires the CVXPY library
Warning
Accepts any backend but will convert to Numpy then back to the backend.
Parameters:
strongly_convex_constant (float, optional) – constant for the strong convexity of the input potential phi, defaults to 0.6
gradient_lipschitz_constant (float, optional) – constant for the Lipschitz property of the input gradient G, defaults to 1.4
its (int, optional) – number of iterations, defaults to 100
Fits the Smooth Strongly Convex Nearest Brenier Potential [58] to the source data Xs to the target data
Xt, with the partition given by the (optional) labels ys.
Wrapper for ot.mapping.nearest_brenier_potential_fit.
Warning
This function requires the CVXPY library
Warning
Accepts any backend but will convert to Numpy then back to the backend.
Parameters:
Xs (array-like (n, d)) – source points used to compute the optimal values phi and G
ys (array-like (n,), optional) – classes of the reference points, defaults to a single class
Xt (array-like (n, d)) – values of the gradients at the reference points X
Computes the images of the new source samples Xs of classes ys by the fitted
Smooth Strongly Convex Nearest Brenier Potentials (SSNB) [58]. The output is the images of two SSNB optimal
maps, called ‘lower’ and ‘upper’ potentials (from [59], Theorem 3.14).
Wrapper for nearest_brenier_potential_predict_bounds.
Warning
This function requires the CVXPY library
Warning
Accepts any backend but will convert to Numpy then back to the backend.
Parameters:
Xs (array-like (m, d)) – input source points
ys (: array_like (m,), optional) – classes of the input source points, defaults to a single class
Returns:
G_lu – gradients of the lower and upper bounding potentials at Y (images of the source inputs)
reg_cl (float, optional (default=0.1)) – Class regularization parameter
max_iter (int, float, optional (default=10)) – The minimum number of iteration before stopping the optimization
algorithm if it has not converged
max_inner_iter (int, float, optional (default=200)) – The number of iteration in the inner loop
tol (float, optional (default=10e-9)) – Stop threshold on error (inner sinkhorn solver) (>0)
verbose (bool, optional (default=False)) – Controls the verbosity of the optimization algorithm
log (bool, optional (default=False)) – Controls the logs of the optimization algorithm
metric (string, optional (default="sqeuclidean")) – The ground metric for the Wasserstein problem
norm (string, optional (default=None)) – If given, normalize the ground metric to avoid numerical errors that
can occur with large metric values.
distribution_estimation (callable, optional (defaults to the uniform)) – The kind of distribution estimation to employ
out_of_sample_map (string, optional (default="ferradans")) – The kind of out of sample mapping to apply to transport samples
from a domain into another one. Currently the only possible option is
“ferradans” which uses the method proposed in [6].
limit_max (float, optional (default=10)) – Controls the semi supervised mode. Transport between labeled source
and target samples of different classes will exhibit an infinite cost
(10 times the maximum value of the cost matrix)
reg_cl (float, optional (default=0.1)) – Class regularization parameter
max_iter (int, float, optional (default=10)) – The minimum number of iteration before stopping the optimization
algorithm if it has not converged
max_inner_iter (int, float, optional (default=200)) – The number of iteration in the inner loop
log (bool, optional (default=False)) – Controls the logs of the optimization algorithm
tol (float, optional (default=10e-9)) – Stop threshold on error (inner sinkhorn solver) (>0)
verbose (bool, optional (default=False)) – Controls the verbosity of the optimization algorithm
metric (string, optional (default="sqeuclidean")) – The ground metric for the Wasserstein problem
norm (string, optional (default=None)) – If given, normalize the ground metric to avoid numerical errors that
can occur with large metric values.
distribution_estimation (callable, optional (defaults to the uniform)) – The kind of distribution estimation to employ
out_of_sample_map (string, optional (default="ferradans")) – The kind of out of sample mapping to apply to transport samples
from a domain into another one. Currently the only possible option is
“ferradans” which uses the method proposed in [6].
limit_max (float, optional (default=np.inf)) – Controls the semi supervised mode. Transport between labeled source
and target samples of different classes will exhibit a cost defined by
limit_max.
max_iter (int, float, optional (default=1000)) – The minimum number of iteration before stopping the optimization
algorithm if it has not converged
tol (float, optional (default=10e-9)) – The precision required to stop the optimization algorithm.
verbose (bool, optional (default=False)) – Controls the verbosity of the optimization algorithm
log (int, optional (default=False)) – Controls the logs of the optimization algorithm
metric (string, optional (default="sqeuclidean")) – The ground metric for the Wasserstein problem
norm (string, optional (default=None)) – If given, normalize the ground metric to avoid numerical errors that
can occur with large metric values. Accepted values are ‘median’,
‘max’, ‘log’ and ‘loglog’.
distribution_estimation (callable, optional (defaults to the uniform)) – The kind of distribution estimation to employ
out_of_sample_map (string, optional (default="continuous")) – The kind of out of sample mapping to apply to transport samples
from a domain into another one. Currently the only possible option is
“ferradans” which uses the nearest neighbor method proposed in [6] while “continuous” use the out of sample
method from [66] and [19].
limit_max (float, optional (default=np.inf)) – Controls the semi supervised mode. Transport between labeled source
and target samples of different classes will exhibit an cost defined
by this variable
reg_m (float, optional (default=0.1)) – Mass regularization parameter
method (str) – method used for the solver either ‘sinkhorn’, ‘sinkhorn_stabilized’ or
‘sinkhorn_epsilon_scaling’, see those function for specific parameters
max_iter (int, float, optional (default=10)) – The minimum number of iteration before stopping the optimization
algorithm if it has not converged
tol (float, optional (default=10e-9)) – Stop threshold on error (inner sinkhorn solver) (>0)
verbose (bool, optional (default=False)) – Controls the verbosity of the optimization algorithm
log (bool, optional (default=False)) – Controls the logs of the optimization algorithm
metric (string, optional (default="sqeuclidean")) – The ground metric for the Wasserstein problem
norm (string, optional (default=None)) – If given, normalize the ground metric to avoid numerical errors that
can occur with large metric values.
distribution_estimation (callable, optional (defaults to the uniform)) – The kind of distribution estimation to employ
out_of_sample_map (string, optional (default="ferradans")) – The kind of out of sample mapping to apply to transport samples
from a domain into another one. Currently the only possible option is
“ferradans” which uses the method proposed in [6].
limit_max (float, optional (default=10)) – Controls the semi supervised mode. Transport between labeled source
and target samples of different classes will exhibit an infinite cost
(10 times the maximum value of the cost matrix)
with \(\mathbf{S^s}_{i,j}, \mathbf{S^t}_{i,j}\) denoting source and target similarity
matrices and \(T(\cdot)\) being a barycentric mapping.
The algorithm used for solving the problem is the conditional gradient algorithm as proposed in
[5].
Parameters:
a (array-like (ns,)) – samples weights in the source domain
b (array-like (nt,)) – samples weights in the target domain
xs (array-like (ns,d)) – samples in the source domain
xt (array-like (nt,d)) – samples in the target domain
M (array-like (ns,nt)) – loss matrix
sim (string, optional) – Type of similarity (‘knn’ or ‘gauss’) used to construct the Laplacian.
sim_param (int or float, optional) – Parameter (number of the nearest neighbors for sim=’knn’
or bandwidth for sim=’gauss’) used to compute the Laplacian.
reg (string) – Type of Laplacian regularization
eta (float) – Regularization term for Laplacian regularization
alpha (float) – Regularization term for source domain’s importance in regularization
numItermax (int, optional) – Max number of iterations
\(\Omega_e\) is the entropic regularization term
\(\Omega_e(\gamma)=\sum_{i,j} \gamma_{i,j}\log(\gamma_{i,j})\)
\(\Omega_g\) is the group lasso regularization term
\(\Omega_g(\gamma)=\sum_{i,c} \|\gamma_{i,\mathcal{I}_c}\|^2\)
where \(\mathcal{I}_c\) are the index of samples from class
c in the source domain.
\(\mathbf{a}\) and \(\mathbf{b}\) are source and target weights (sum to 1)
The algorithm used for solving the problem is the generalized conditional
gradient as proposed in [5, 7].
Parameters:
a (array-like (ns,)) – samples weights in the source domain
labels_a (array-like (ns,)) – labels of samples in the source domain
b (array-like (nt,)) – samples in the target domain
M (array-like (ns,nt)) – loss matrix
reg (float) – Regularization term for entropic regularization >0
eta (float, optional) – Regularization term for group lasso regularization >0
numItermax (int, optional) – Max number of iterations
numInnerItermax (int, optional) – Max number of iterations (inner sinkhorn solver)
\(\Omega_e\) is the entropic regularization term \(\Omega_e
(\gamma)=\sum_{i,j} \gamma_{i,j}\log(\gamma_{i,j})\)
\(\Omega_g\) is the group lasso regularization term
\(\Omega_g(\gamma)=\sum_{i,c} \|\gamma_{i,\mathcal{I}_c}\|^{1/2}_1\)
where \(\mathcal{I}_c\) are the index of samples from class c
in the source domain.
\(\mathbf{a}\) and \(\mathbf{b}\) are source and target weights (sum to 1)
The algorithm used for solving the problem is the generalized conditional
gradient as proposed in [5, 7].
Parameters:
a (array-like (ns,)) – samples weights in the source domain
labels_a (array-like (ns,)) – labels of samples in the source domain
b (array-like (nt,)) – samples weights in the target domain
M (array-like (ns,nt)) – loss matrix
reg (float) – Regularization term for entropic regularization >0
eta (float, optional) – Regularization term for group lasso regularization >0
numItermax (int, optional) – Max number of iterations
numInnerItermax (int, optional) – Max number of iterations (inner sinkhorn solver)