【发布时间】:2021-02-09 09:31:49
【问题描述】:
我在代码下面运行,而我收到一个错误,比如只有整数标量值转换为标量索引..
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import MinMaxScaler
X_train, X_test, Y_train, Y_test = train_test_split(X, Y, test_size=0.1, random_state=0)
min_max_scaler = MinMaxScaler()
X_train = min_max_scaler.fit_transform(X_train)
rbm_train=rbm_model_1.fit_transform(X_train )
X_train=sc.fit_transform(X_train) ----> this line causing error
X =[[0.00000000e+00 1.76100000e+03 3.02434414e-02 ... 1.00505479e+01
6.90634415e+00 1.13641060e+01]
[1.00000000e+00 5.54300000e+03 3.32540176e-01 ... 9.66597699e+01
7.81453418e+01 2.94180046e+02]
[2.00000000e+00 3.44800000e+03 1.35616750e-01 ... 2.77757100e+01
2.95552513e+01 6.49203725e+01]
...
[5.85600000e+03 3.37100000e+03 1.99433359e-01 ... 1.82494245e+01
2.96294395e+01 4.89311229e+01]
[5.85700000e+03 4.59700000e+03 3.33133906e-01 ... 4.38591971e+01
6.63558086e+01 5.51086311e+01]
[5.85800000e+03 4.82800000e+03 3.91628974e-01 ... 6.50556871e+01
1.02210562e+02 5.93112050e+01]]
y= [0. 0. 0. ... 1. 1. 1.]
X_train = [[-0.78210062 0.14111439 -0.3656736 ... -0.06997126
-0.14909763
-0.54753418]
[-0.51177349 -0.77928848 -0.47345634 ... -0.24668018 -0.17406007
-0.67165109]
[ 0.07797737 -0.54963283 -0.45941915 ... -0.26573143 -0.21174211
-0.61647054]
...
[-0.75134129 -1.29734889 -0.59546654 ... -0.328803 -0.25774714
-0.69402226]
[-0.18702603 -0.3460879 -0.58283771 ... -0.24237006 -0.26603587
-0.59759254]
[-0.11308535 -0.82498224 -0.50012261 ... -0.3001251 -0.22795859
-0.64925682]]
这些是我之前为 X、Y、X_train 获得的输出...我有这些值,但是在将其反射转换为只有整数标量数组可以转换为标量索引时
【问题讨论】:
-
您的数据形状可能是错误的。你能发布一个小的可重现的例子吗?
标签: python multidimensional-array scikit-learn typeerror scalar