Skip to content

Instantly share code, notes, and snippets.

@rajatpaliwal
Created February 10, 2018 12:35
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 rajatpaliwal/a87ea13f39756e6abd6a1c3ddbc3d3d1 to your computer and use it in GitHub Desktop.
Save rajatpaliwal/a87ea13f39756e6abd6a1c3ddbc3d3d1 to your computer and use it in GitHub Desktop.
def sort(any):
less=[]
equal=[]
large=[]
if len(any)>1:
pivot=any[0]
for x in any:
if x<pivot:
less.append(x)
if x==pivot:
equal.append(x)
if x>pivot:
large.append(x)
return sort(less)+equal+sort(large)
else:
return any
def featureScaling(arr):
frsh=[]
new= sort(arr)
maxm= new[-1]
minm= new[0]
if len(new)>3:
for x in new[1:-2]:
scaled= (x-minm)/(maxm-minm)
frsh.append(scaled)
return frsh
else:
answer= float(float(new[1]-minm)/float(maxm-minm))
return answer
# tests of your feature scaler--line below is input data
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