---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-48-9a56f92ca2dd> in <module>()
1 from sklearn.preprocessing import scale
----> 2 X_transform = scale(X_transform)
/opt/conda/lib/python3.6/site-packages/sklearn/preprocessing/data.py in scale(X, axis, with_mean, with_std, copy)
143 X = check_array(X, accept_sparse='csc', copy=copy, ensure_2d=False,
144 warn_on_dtype=True, estimator='the scale function',
--> 145 dtype=FLOAT_DTYPES, force_all_finite='allow-nan')
146 if sparse.issparse(X):
147 if with_mean:
/opt/conda/lib/python3.6/site-packages/sklearn/utils/validation.py in check_array(array, accept_sparse, accept_large_sparse, dtype, order, copy, force_all_finite, ensure_2d, allow_nd, ensure_min_samples, ensure_min_features, warn_on_dtype, estimator)
525 try:
526 warnings.simplefilter('error', ComplexWarning)
--> 527 array = np.asarray(array, dtype=dtype, order=order)
528 except ComplexWarning:
529 raise ValueError("Complex data not supported\n"
/opt/conda/lib/python3.6/site-packages/numpy/core/numeric.py in asarray(a, dtype, order)
499
500 """
--> 501 return array(a, dtype, copy=False, order=order)
502
503
ValueError: setting an array element with a sequence.
这是我的代码X_transform
是大小为16000*300
的数组
from sklearn.preprocessing import scale
X_transform = scale(X_transform)
我要去哪里错了?它包含浮点类型的值。
答案 0 :(得分:1)
X_transform
不是浮点数的数组。正确地将其转换为数组(2D数组,而不是1D数组的1D数组),然后它将按预期工作。