"Machine Learning Path" Code Error Resolution

In the learning process found on page 39 of a code error is always normalized
Scaler = preprocessing.StandardScaler ()
DF [ 'Age_scaled'] = scaler.fit_transform (data_train [ 'Age'])
DF [ 'Fare_scaled'] = scaler.fit_transform (data_train [ 'Fare'])
Error resultslater modify the code according to the error data_train [ 'Age'] and data_train [ 'Fare'] plus reshape (1, -1) is still given! ! !
After the advice of your mother know Python version of the problem, reshape method was canceled in the follow-up, so instead values.reshape (-1,1)
finally succeeded

scaler = preprocessing.StandardScaler()
df['Age_scaled'] = scaler.fit_transform(data_train['Age'].values.reshape(-1,1))
df['Fare_scaled'] = scaler.fit_transform(data_train['Fare'].values.reshape(-1,1))

Released nine original articles · won praise 2 · Views 3090

Guess you like

Origin blog.csdn.net/xiaokan_001/article/details/87862550