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

Function label_normalization

ot/utils.py:507–527  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

505
506
507def 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
530def labels_to_masks(y, type_as=None, nx=None):

Callers 4

transform_labelsMethod · 0.85
transform_labelsMethod · 0.85

Calls 2

get_backendFunction · 0.85
minMethod · 0.45

Tested by

no test coverage detected