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

Method fit

ot/da.py:2383–2435  ·  view source on GitHub ↗

r"""Building coupling matrices from a list of source and target sets of samples :math:`(\mathbf{X_s}, \mathbf{y_s})` and :math:`(\mathbf{X_t}, \mathbf{y_t})` Parameters ---------- Xs : list of K array-like objects, shape K x (nk_source_samples, n_features)

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

Source from the content-addressed store, hash-verified

2381 self.out_of_sample_map = out_of_sample_map
2382
2383 def fit(self, Xs, ys=None, Xt=None, yt=None):
2384 r"""Building coupling matrices from a list of source and target sets of samples
2385 :math:`(\mathbf{X_s}, \mathbf{y_s})` and :math:`(\mathbf{X_t}, \mathbf{y_t})`
2386
2387 Parameters
2388 ----------
2389 Xs : list of K array-like objects, shape K x (nk_source_samples, n_features)
2390 A list of the training input samples.
2391 ys : list of K array-like objects, shape K x (nk_source_samples,)
2392 A list of the class labels
2393 Xt : array-like, shape (n_target_samples, n_features)
2394 The training input samples.
2395 yt : array-like, shape (n_target_samples,)
2396 The class labels. If some target samples are unlabelled, fill the
2397 :math:`\mathbf{y_t}`'s elements with -1.
2398
2399 Warning: Note that, due to this convention -1 cannot be used as a
2400 class label
2401
2402 Returns
2403 -------
2404 self : object
2405 Returns self.
2406 """
2407 self._get_backend(*Xs, *ys, Xt, yt)
2408
2409 # check the necessary inputs parameters are here
2410 if check_params(Xs=Xs, Xt=Xt, ys=ys):
2411 self.xs_ = Xs
2412 self.xt_ = Xt
2413
2414 returned_ = jcpot_barycenter(
2415 Xs=Xs,
2416 Ys=ys,
2417 Xt=Xt,
2418 reg=self.reg_e,
2419 metric=self.metric,
2420 distrinumItermax=self.max_iter,
2421 stopThr=self.tol,
2422 verbose=self.verbose,
2423 log=True,
2424 )
2425
2426 self.coupling_ = returned_[1]["gamma"]
2427
2428 # deal with the value of log
2429 if self.log:
2430 self.proportions_, self.log_ = returned_
2431 else:
2432 self.proportions_ = returned_
2433 self.log_ = dict()
2434
2435 return self
2436
2437 def transform(self, Xs=None, ys=None, Xt=None, yt=None, batch_size=128):
2438 r"""Transports source samples :math:`\mathbf{X_s}` onto target ones :math:`\mathbf{X_t}`

Callers 1

Calls 3

check_paramsFunction · 0.85
jcpot_barycenterFunction · 0.85
_get_backendMethod · 0.80

Tested by 1