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

Method inverse_transform_labels

ot/da.py:832–859  ·  view source on GitHub ↗

r"""Propagate target labels :math:`\mathbf{y_t}` to obtain estimated source labels :math:`\mathbf{y_s}` Parameters ---------- yt : array-like, shape (n_target_samples,) Returns ------- transp_ys : array-like, shape (n_source_samples, nb_class

(self, yt=None)

Source from the content-addressed store, hash-verified

830 return transp_Xt
831
832 def inverse_transform_labels(self, yt=None):
833 r"""Propagate target labels :math:`\mathbf{y_t}` to obtain estimated source labels
834 :math:`\mathbf{y_s}`
835
836 Parameters
837 ----------
838 yt : array-like, shape (n_target_samples,)
839
840 Returns
841 -------
842 transp_ys : array-like, shape (n_source_samples, nb_classes)
843 Estimated soft source labels.
844 """
845 nx = self.nx
846
847 # check the necessary inputs parameters are here
848 if check_params(yt=yt):
849 # perform label propagation
850 transp = self.coupling_ / nx.sum(self.coupling_, 1)[:, None]
851 # set nans to 0
852 transp = nx.nan_to_num(transp, nan=0, posinf=0, neginf=0)
853
854 # compute propagated labels
855 labels = label_normalization(yt)
856 masks = labels_to_masks(labels, nx=nx, type_as=transp)
857 transp_ys = nx.dot(masks.T, transp.T)
858
859 return transp_ys.T
860
861
862class LinearTransport(BaseTransport):

Calls 6

check_paramsFunction · 0.85
label_normalizationFunction · 0.85
labels_to_masksFunction · 0.85
sumMethod · 0.45
nan_to_numMethod · 0.45
dotMethod · 0.45