Skip to content

Instantly share code, notes, and snippets.

@a-r-d
Created March 8, 2018 20:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save a-r-d/e7504d57a0e05125ed68c60198e55489 to your computer and use it in GitHub Desktop.
Save a-r-d/e7504d57a0e05125ed68c60198e55489 to your computer and use it in GitHub Desktop.
how to scale factors
def featureScaling(arr):
_max = 0
_min = 10000000
for a in arr:
if a < _min:
_min = a
if a > _max:
_max = a
scaled = []
for a in arr:
scaled.append((a - _min) / float((_max - _min)))
return scaled
data = [115, 140, 175]
print featureScaling(data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment