Utility functions for the package.
utils.
scale_01
Scales array to 0-1.
x (iter) – 1d array of float
scaled 1d array
np.array
Example
>>> scale_01([1, 2, 3, 5]).tolist() [0.0, 0.25, 0.5, 1.0]
abs_distance
Returns absolute distance.
x (float) – input 1
y (float) – input 2
|x-y|
float
>>> abs_distance(5, 7) 2.0 >>> abs_distance(4, 1) 3.0
euclidean_distance
Returns Euclidean distance.
x (float or iter) – input 1
y (float or iter) – input 2
Euclidean distance
References
https://numpy.org/doc/stable/reference/generated/numpy.linalg.norm.html
Examples
>>> x, y = 1, 2 >>> euclidean_distance(x, y) 1.0 >>> x, y = [1, 2], [4, 6] >>> euclidean_distance(x, y) 5.0