summaryrefslogtreecommitdiff
path: root/ot/utils.py
diff options
context:
space:
mode:
authorIevgen Redko <ievgen.redko@univ-st-etienne.fr>2020-04-15 17:02:18 +0200
committerGitHub <noreply@github.com>2020-04-15 17:02:18 +0200
commitf9499dce4e14c39bd42efeee22ad861933326a8b (patch)
tree73c0bc7021b945d43b667cea76e4424e5f6e1147 /ot/utils.py
parent2571a3ead11a7fc010ed20b1af6faeef464565a1 (diff)
parentadc5570550676b63b9aabb2205a67c5b7c9187f3 (diff)
Merge branch 'master' into laplace_da
Diffstat (limited to 'ot/utils.py')
-rw-r--r--ot/utils.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/ot/utils.py b/ot/utils.py
index a633be2..f9911a1 100644
--- a/ot/utils.py
+++ b/ot/utils.py
@@ -206,6 +206,28 @@ def dots(*args):
return reduce(np.dot, args)
+def label_normalization(y, start=0):
+ """ 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 y (default=0)
+
+ Returns
+ -------
+ y : array-like, shape (n1, )
+ The input vector of labels normalized according to given start value.
+ """
+
+ diff = np.min(np.unique(y)) - start
+ if diff != 0:
+ y -= diff
+ return y
+
+
def fun(f, q_in, q_out):
""" Utility function for parmap with no serializing problems """
while True: