Python Forum
Error while writing a code for feature scaling - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Error while writing a code for feature scaling (/thread-4427.html)



Error while writing a code for feature scaling - prateek - Aug-15-2017

Hi, I am trying to write a code for doing feature scaling but getting an error. Please help me out with this.

def featureScaling(arr):
ndata = []
for e in arr:
x = float((e-min(arr))/(max(arr)-min(arr)))
ndata.append(x)

return ndata

data = [115, 140, 175]
print featureScaling(data)



Ouput i am getting - [0.0, 0.0, 1.0]

Correct Output - [0.0, 0.41, 1.0]


RE: Error while writing a code for feature scaling - Larz60+ - Aug-15-2017

Please fix indentation (use ctrl-shift-v when pasting) and enclose in code tags (BBCODE)