Python Forum
Error while writing a code for feature scaling
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error while writing a code for feature scaling
#1
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]
Reply
#2
Please fix indentation (use ctrl-shift-v when pasting) and enclose in code tags (BBCODE)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  writing and running code in vscode without saving it akbarza 1 345 Jan-11-2024, 02:59 PM
Last Post: deanhystad
  add mqtt feature to existing code Positron79 0 567 Jan-31-2023, 05:56 PM
Last Post: Positron79
  Help with writing or plan part of code Merlin_1 1 1,779 Aug-24-2020, 03:28 AM
Last Post: Larz60+
  Writing a basic shift code djwilson0495 2 2,220 Aug-16-2020, 01:52 PM
Last Post: djwilson0495
  a better way of writing code Than999 6 3,283 Jun-13-2020, 08:02 AM
Last Post: pyzyx3qwerty
  Error When Writing to SQL Table skaailet 1 1,791 Jun-10-2020, 12:01 AM
Last Post: bowlofred
  vs code interpreter vs IDLE feature tsmspace 4 4,149 Apr-01-2020, 10:45 PM
Last Post: kiliman13
  code not writing to projNameVal portion of code. umkc1 1 1,644 Feb-05-2020, 10:05 PM
Last Post: Larz60+
  C API: Writing Executed Code to a File myanrueller 0 1,672 Nov-17-2019, 09:35 PM
Last Post: myanrueller
  i am getting error while writing code for exception logging rkgupta51179 1 1,814 Nov-03-2019, 05:12 AM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020