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,) The target class labels Returns ------- transp_ys : list of K
(self, yt=None)
| 2559 | return yt.T |
| 2560 | |
| 2561 | def inverse_transform_labels(self, yt=None): |
| 2562 | r"""Propagate target labels :math:`\mathbf{y_t}` to obtain estimated source labels |
| 2563 | :math:`\mathbf{y_s}` |
| 2564 | |
| 2565 | Parameters |
| 2566 | ---------- |
| 2567 | yt : array-like, shape (n_target_samples,) |
| 2568 | The target class labels |
| 2569 | |
| 2570 | Returns |
| 2571 | ------- |
| 2572 | transp_ys : list of K array-like objects, shape K x (nk_source_samples, nb_classes) |
| 2573 | A list of estimated soft source labels |
| 2574 | """ |
| 2575 | nx = self.nx |
| 2576 | |
| 2577 | # check the necessary inputs parameters are here |
| 2578 | if check_params(yt=yt): |
| 2579 | transp_ys = [] |
| 2580 | ytTemp = label_normalization(yt) |
| 2581 | classes = nx.unique(ytTemp) |
| 2582 | n = len(classes) |
| 2583 | D1 = nx.zeros((n, len(ytTemp)), type_as=self.coupling_[0]) |
| 2584 | |
| 2585 | for c in classes: |
| 2586 | D1[int(c), ytTemp == c] = 1 |
| 2587 | |
| 2588 | for i in range(len(self.xs_)): |
| 2589 | # perform label propagation |
| 2590 | transp = self.coupling_[i] / nx.sum(self.coupling_[i], 1)[:, None] |
| 2591 | |
| 2592 | # set nans to 0 |
| 2593 | transp = nx.nan_to_num(transp, nan=0, posinf=0, neginf=0) |
| 2594 | |
| 2595 | # compute propagated labels |
| 2596 | transp_ys.append(nx.dot(D1, transp.T).T) |
| 2597 | |
| 2598 | return transp_ys |
| 2599 | |
| 2600 | |
| 2601 | class NearestBrenierPotential(BaseTransport): |