Jan-08-2020, 04:59 PM
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
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