Created
February 10, 2018 12:35
-
-
Save rajatpaliwal/a87ea13f39756e6abd6a1c3ddbc3d3d1 to your computer and use it in GitHub Desktop.
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
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