Created
May 29, 2020 00:30
-
-
Save JupyterJones/ee54ba2ade06dc14f14d5952d118cc18 to your computer and use it in GitHub Desktop.
Normalize - Ranges any span of numeric data in a list between 0-1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
''' | |
Ranges any span of numeric data in a list between 0-1 | |
Usage: | |
from NormalizeData import * | |
DATA = [1,34,546,3985,857463,49495857] | |
NormalizeData(DATA) | |
>>> array([0.00000000e+00, 6.66722483e-07, 1.10110228e-05, 8.04915870e-05, | |
1.73239150e-02, 1.00000000e+00]) | |
''' | |
import numpy as np | |
def NormalizeData(DATA): | |
data = np.asarray(DATA) | |
return (data - np.min(data)) / (np.max(data) - np.min(data)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment