我正在尝试对局部变量 x_vals 中的数据执行min-max标准化,我将其转换为数据帧
x_value = pd.DataFrame(data=x_vals)
有
[506行x 1列]
样本数据如下所述
0
0 [0.00632, 2.31, 6.575, 65.2, 4.09, 296.0, 396....
1 [0.02731, 7.07, 6.421, 78.9, 4.9671, 242.0, 39...
2 [0.02729, 7.07, 7.185, 61.1, 4.9671, 242.0, 39...
3 [0.03237, 2.18, 6.998, 45.8, 6.0622, 222.0, 39...
4 [0.06905, 2.18, 7.147, 54.2, 6.0622, 222.0, 39...
5 [0.02985, 2.18, 6.43, 58.7, 6.0622, 222.0, 394...
6 [0.08829, 7.87, 6.012, 66.6, 5.5605, 311.0, 39...
7 [0.14455, 7.87, 6.172, 96.1, 5.9505, 311.0, 39...
8 [0.21124, 7.87, 5.631, 100.0, 6.0821, 311.0, 3...
9 [0.17004, 7.87, 6.004, 85.9, 6.5921, 311.0, 38...
10 [0.22489, 7.87, 6.377, 94.3, 6.3467, 311.0, 39...
并转换为标准化格式我做了
scaler = MinMaxScaler(feature_range=(0,1))
scaler = scaler.fit(x_value.values)
print(scaler)
并显示错误
追踪(最近一次通话): 文件" knn.py",第33行,in scaler = scaler.fit(x_value.values) 文件" /usr/local/lib/python2.7/dist-packages/sklearn/preprocessing/data.py" ;,第308行,in fit return self.partial_fit(X,y) 文件" /usr/local/lib/python2.7/dist-packages/sklearn/preprocessing/data.py" ;,第334行,在partial_fit中 estimator = self,dtype = FLOAT_DTYPES) 文件" /usr/local/lib/python2.7/dist-packages/sklearn/utils/validation.py" ;,第433行,在check_array中 array = np.array(array,dtype = dtype,order = order,copy = copy) ValueError:使用序列设置数组元素。
如何标准化数据? 谢谢!