Python Forum
Code used to work, not anymore for no apparent reason?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Code used to work, not anymore for no apparent reason?
#1
Hello,

I am taking Microsoft Professional Program for Artificial Intelligence. This block of code used to work fine. After I tried to insert some new code before it, I start to get the NameError message. I know it is not valid because it worked before. I tried to shut down the server, log out and in a few times. Still getting it. Please help!

scaler = preprocessing.StandardScaler().fit(X_train[:,20:])
X_train[:,20:] = scaler.transform(X_train[:,20:])
X_test[:,20:] = scaler.transform(X_test[:,20:])
X_train[:2,]

NameErrorTraceback (most recent call last)
<ipython-input-4-8e772dc33ff2> in <module>()
2 ## Notice that the scaler is fit only on the training data. The trained scaler is then applied to the test data.
3 ## Test data should always be scaled using the parameters from the training data
----> 4 scaler = preprocessing.StandardScaler().fit(X_train[:,20:])
5 X_train[:,20:] = scaler.transform(X_train[:,20:])
6 X_test[:,20:] = scaler.transform(X_test[:,20:])

NameError: name 'preprocessing' is not defined
Reply


Messages In This Thread
Code used to work, not anymore for no apparent reason? - by chicagoxjl - Jan-08-2020, 04:59 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  coma separator is printed on a new line for some reason tester_V 4 536 Feb-02-2024, 06:06 PM
Last Post: tester_V
  hi need help to make this code work correctly atulkul1985 5 829 Nov-20-2023, 04:38 PM
Last Post: deanhystad
  newbie question - can't make code work tronic72 2 717 Oct-22-2023, 09:08 PM
Last Post: tronic72
  Beginner: Code not work when longer list raiviscoding 2 850 May-19-2023, 11:19 AM
Last Post: deanhystad
  Why doesn't this code work? What is wrong with path? Melcu54 7 1,870 Jan-29-2023, 06:24 PM
Last Post: Melcu54
  Code used to work 100%, now sometimes works! muzicman0 5 1,482 Jan-13-2023, 05:09 PM
Last Post: muzicman0
  color code doesn't work harryvl 1 919 Dec-29-2022, 08:59 PM
Last Post: deanhystad
  Something the code dont work AlexPython 13 2,314 Oct-17-2022, 08:34 PM
Last Post: AlexPython
  cannot get code to work Led_Zeppelin 10 2,503 Jun-30-2022, 06:28 PM
Last Post: deanhystad
  How does this code work? pd_minh12 3 1,381 Apr-15-2022, 02:50 AM
Last Post: Pedroski55

Forum Jump:

User Panel Messages

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