r"""Transform labels to start at a given value Parameters ---------- y : array-like, shape (n, ) The vector of labels to be normalized. start : int Desired value for the smallest label in :math:`\mathbf{y}` (default=0) nx : Backend, optional Backend to pe
(y, start=0, nx=None)
| 505 | |
| 506 | |
| 507 | def label_normalization(y, start=0, nx=None): |
| 508 | r"""Transform labels to start at a given value |
| 509 | |
| 510 | Parameters |
| 511 | ---------- |
| 512 | y : array-like, shape (n, ) |
| 513 | The vector of labels to be normalized. |
| 514 | start : int |
| 515 | Desired value for the smallest label in :math:`\mathbf{y}` (default=0) |
| 516 | nx : Backend, optional |
| 517 | Backend to perform computations on. If omitted, the backend defaults to that of `y`. |
| 518 | |
| 519 | Returns |
| 520 | ------- |
| 521 | y : array-like, shape (`n1`, ) |
| 522 | The input vector of labels normalized according to given start value. |
| 523 | """ |
| 524 | if nx is None: |
| 525 | nx = get_backend(y) |
| 526 | diff = nx.min(y) - start |
| 527 | return y if diff == 0 else (y - diff) |
| 528 | |
| 529 | |
| 530 | def labels_to_masks(y, type_as=None, nx=None): |
no test coverage detected