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

Method fit

ot/da.py:2062–2134  ·  view source on GitHub ↗

r"""Builds an optimal coupling and estimates the associated mapping from source and target sets of samples :math:`(\mathbf{X_s}, \mathbf{y_s})` and :math:`(\mathbf{X_t}, \mathbf{y_t})` Parameters ---------- Xs : array-like, shape (n_source_samples, n_features

(self, Xs=None, ys=None, Xt=None, yt=None)

Source from the content-addressed store, hash-verified

2060 self.verbose2 = verbose2
2061
2062 def fit(self, Xs=None, ys=None, Xt=None, yt=None):
2063 r"""Builds an optimal coupling and estimates the associated mapping
2064 from source and target sets of samples
2065 :math:`(\mathbf{X_s}, \mathbf{y_s})` and :math:`(\mathbf{X_t}, \mathbf{y_t})`
2066
2067 Parameters
2068 ----------
2069 Xs : array-like, shape (n_source_samples, n_features)
2070 The training input samples.
2071 ys : array-like, shape (n_source_samples,)
2072 The class labels
2073 Xt : array-like, shape (n_target_samples, n_features)
2074 The training input samples.
2075 yt : array-like, shape (n_target_samples,)
2076 The class labels. If some target samples are unlabelled, fill the
2077 :math:`\mathbf{y_t}`'s elements with -1.
2078
2079 Warning: Note that, due to this convention -1 cannot be used as a
2080 class label
2081
2082 Returns
2083 -------
2084 self : object
2085 Returns self
2086 """
2087 self._get_backend(Xs, ys, Xt, yt)
2088
2089 # check the necessary inputs parameters are here
2090 if check_params(Xs=Xs, Xt=Xt):
2091 self.xs_ = Xs
2092 self.xt_ = Xt
2093
2094 if self.kernel == "linear":
2095 returned_ = joint_OT_mapping_linear(
2096 Xs,
2097 Xt,
2098 mu=self.mu,
2099 eta=self.eta,
2100 bias=self.bias,
2101 verbose=self.verbose,
2102 verbose2=self.verbose2,
2103 numItermax=self.max_iter,
2104 numInnerItermax=self.max_inner_iter,
2105 stopThr=self.tol,
2106 stopInnerThr=self.inner_tol,
2107 log=self.log,
2108 )
2109
2110 elif self.kernel == "gaussian":
2111 returned_ = joint_OT_mapping_kernel(
2112 Xs,
2113 Xt,
2114 mu=self.mu,
2115 eta=self.eta,
2116 bias=self.bias,
2117 sigma=self.sigma,
2118 verbose=self.verbose,
2119 verbose2=self.verbose,

Calls 4

check_paramsFunction · 0.85
joint_OT_mapping_linearFunction · 0.85
joint_OT_mapping_kernelFunction · 0.85
_get_backendMethod · 0.80