Compute left and right factors corresponding to the Nystroem method on the Gaussian kernel \(K(x^s_i, x^t_j) = \exp(-\|x^s_i-x^t_j\|^2/2\sigma^2)\).
The Nystroem approximation is computed by sampling \(\min(n, \lceil(c / 2))\rceil)\) components in each distribution,
where \(n\) is the number of samples in the distribution and \(c\) the total number of anchor points.
Parameters:
X_s (array-like, shape (n_samples_a, dim)) – samples in the source domain
X_t (array-like, shape (n_samples_b, dim)) – samples in the target domain
anchors (int, optional) – The total number of anchors sampled for the Nystroem approximation (anchors/2 in each distribution), default 50.
sigma (float, optional) – The standard deviation parameter for the Gaussian kernel.
random_state (int, optional) – The random state for sampling the components in each distribution.
Returns:
left_factor (array-like, shape (n_samples_a, dim_r)) – Left factor of Nystroem
right_factor (array-like, shape (n_samples_b, dim_r)) – Right factor of Nystroem
rank (int, optional. Default is None. (>0)) – Nonnegative rank of the OT plan. If None, min(ns, nt) is considered.
alpha (int, optional. Default is 1e-10. (>0 and <1/r)) – Lower bound for the weight vector g.
rescale_cost (bool, optional. Default is False) – Rescale the low rank factorization of the sqeuclidean cost matrix
init (str, optional. Default is 'random'.) – Initialization strategy for the low rank couplings. ‘random’, ‘deterministic’ or ‘kmeans’
reg_init (float, optional. Default is 1e-1. (>0)) – Regularization term for a ‘kmeans’ init. If None, 1 is considered.
seed_init (int, optional. Default is 49. (>0)) – Random state for a ‘random’ or ‘kmeans’ init strategy.
gamma_init (str, optional. Default is "rescale".) – Initialization strategy for gamma. ‘rescale’, or ‘theory’
Gamma is a constant that scales the convergence criterion of the Mirror Descent
optimization scheme used to compute the low-rank couplings (Q, R and g)
numItermax (int, optional. Default is 2000.) – Max number of iterations for the Dykstra algorithm
stopThr (float, optional. Default is 1e-7.) – Stop threshold on error (>0) in Dykstra
warn (bool, optional) – if True, raises a warning if the algorithm doesn’t convergence.
Compute the Sinkhorn algorithm for a kernel \(\mathbf{K}\) that can be written as a low rank factorization \(\mathbf{K} = \mathbf{K}_1 \mathbf{K}_2^\top\).
Does not implement multiple targets.
Precisely :
\(\mathbf{K}_1, \mathbf{K}_2\) are the (dim_a, dim_r), (dim_b, dim_r) kernel matrices
\(\Omega\) is the entropic regularization term
\(\Omega(\gamma)=\sum_{i,j} \gamma_{i,j}\log(\gamma_{i,j})\)
\(\mathbf{a}\) and \(\mathbf{b}\) are source and target
weights (histograms, both sum to 1)
The algorithm used for solving the problem is the Sinkhorn-Knopp
matrix scaling algorithm as proposed in [2]
Parameters:
K_1 (array-like, shape (n_samples_a, dim_r)) – Left factor
K_2 (array-like, shape (n_samples_b, dim_r)) – Right factor
a (array-like, shape (n_samples_a,)) – samples weights in the source domain
b (array-like, shape (n_samples_b,)) – samples in the target domain
numItermax (int, optional) – Max number of iterations
stopThr (float, optional) – Stop threshold on error (>0)
verbose (bool, optional) – Print information along iterations
warn (bool, optional) – if True, raises a warning if the algorithm doesn’t convergence.
warmstart (tuple of arrays, shape (n_samples_a, n_samples_b), optional) – Initialization of dual potentials. If provided, the dual potentials should be given
(that is the logarithm of the u,v sinkhorn scaling vectors)
Returns:
u (array-like, shape (n_samples_a, )) – Left dual variable
v (array-like, shape (n_samples_b, )) – Right dual variable
log (dict (lazy_plan)) – log dictionary return only if log==True in parameters
Examples using ot.lowrank.sinkhorn_low_rank_kernel
Compute left and right factors corresponding to the Nystroem method on the Gaussian kernel \(K(x^s_i, x^t_j) = \exp(-\|x^s_i-x^t_j\|^2/2\sigma^2)\).
The Nystroem approximation is computed by sampling \(\min(n, \lceil(c / 2))\rceil)\) components in each distribution,
where \(n\) is the number of samples in the distribution and \(c\) the total number of anchor points.
Parameters:
X_s (array-like, shape (n_samples_a, dim)) – samples in the source domain
X_t (array-like, shape (n_samples_b, dim)) – samples in the target domain
anchors (int, optional) – The total number of anchors sampled for the Nystroem approximation (anchors/2 in each distribution), default 50.
sigma (float, optional) – The standard deviation parameter for the Gaussian kernel.
random_state (int, optional) – The random state for sampling the components in each distribution.
Returns:
left_factor (array-like, shape (n_samples_a, dim_r)) – Left factor of Nystroem
right_factor (array-like, shape (n_samples_b, dim_r)) – Right factor of Nystroem
rank (int, optional. Default is None. (>0)) – Nonnegative rank of the OT plan. If None, min(ns, nt) is considered.
alpha (int, optional. Default is 1e-10. (>0 and <1/r)) – Lower bound for the weight vector g.
rescale_cost (bool, optional. Default is False) – Rescale the low rank factorization of the sqeuclidean cost matrix
init (str, optional. Default is 'random'.) – Initialization strategy for the low rank couplings. ‘random’, ‘deterministic’ or ‘kmeans’
reg_init (float, optional. Default is 1e-1. (>0)) – Regularization term for a ‘kmeans’ init. If None, 1 is considered.
seed_init (int, optional. Default is 49. (>0)) – Random state for a ‘random’ or ‘kmeans’ init strategy.
gamma_init (str, optional. Default is "rescale".) – Initialization strategy for gamma. ‘rescale’, or ‘theory’
Gamma is a constant that scales the convergence criterion of the Mirror Descent
optimization scheme used to compute the low-rank couplings (Q, R and g)
numItermax (int, optional. Default is 2000.) – Max number of iterations for the Dykstra algorithm
stopThr (float, optional. Default is 1e-7.) – Stop threshold on error (>0) in Dykstra
warn (bool, optional) – if True, raises a warning if the algorithm doesn’t convergence.
Compute the Sinkhorn algorithm for a kernel \(\mathbf{K}\) that can be written as a low rank factorization \(\mathbf{K} = \mathbf{K}_1 \mathbf{K}_2^\top\).
Does not implement multiple targets.
Precisely :
\(\mathbf{K}_1, \mathbf{K}_2\) are the (dim_a, dim_r), (dim_b, dim_r) kernel matrices
\(\Omega\) is the entropic regularization term
\(\Omega(\gamma)=\sum_{i,j} \gamma_{i,j}\log(\gamma_{i,j})\)
\(\mathbf{a}\) and \(\mathbf{b}\) are source and target
weights (histograms, both sum to 1)
The algorithm used for solving the problem is the Sinkhorn-Knopp
matrix scaling algorithm as proposed in [2]
Parameters:
K_1 (array-like, shape (n_samples_a, dim_r)) – Left factor
K_2 (array-like, shape (n_samples_b, dim_r)) – Right factor
a (array-like, shape (n_samples_a,)) – samples weights in the source domain
b (array-like, shape (n_samples_b,)) – samples in the target domain
numItermax (int, optional) – Max number of iterations
stopThr (float, optional) – Stop threshold on error (>0)
verbose (bool, optional) – Print information along iterations
warn (bool, optional) – if True, raises a warning if the algorithm doesn’t convergence.
warmstart (tuple of arrays, shape (n_samples_a, n_samples_b), optional) – Initialization of dual potentials. If provided, the dual potentials should be given
(that is the logarithm of the u,v sinkhorn scaling vectors)
Returns:
u (array-like, shape (n_samples_a, )) – Left dual variable
v (array-like, shape (n_samples_b, )) – Right dual variable
log (dict (lazy_plan)) – log dictionary return only if log==True in parameters