我正在尝试理解并运行此code。错误是尝试通过使用scaler.transform转换为数组来重塑测试数据时。
train_data = train_data.reshape(-1)
test_data = scaler.transform(test_data).reshape(-1) #error!
输出错误消息:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-55-c702803dbbe6> in <module>
11 # Normalize test data
---> 13 test_data = scaler.transform(test_data).reshape(-1)
~/StockPrediction/predictionLSTM/pro1/lib/python3.7/site-packages/sklearn/preprocessing/_data.py in transform(self, X)
406
407 X = check_array(X, copy=self.copy, dtype=FLOAT_DTYPES,
--> 408 force_all_finite="allow-nan")
409
410 X *= self.scale_
~/StockPrediction/predictionLSTM/pro1/lib/python3.7/site-packages/sklearn/utils/validation.py in inner_f(*args, **kwargs)
70 FutureWarning)
71 kwargs.update({k: arg for k, arg in zip(sig.parameters, args)})
---> 72 return f(**kwargs)
73 return inner_f
74
~/StockPrediction/predictionLSTM/pro1/lib/python3.7/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, estimator)
651 " minimum of %d is required%s."
652 % (n_samples, array.shape, ensure_min_samples,
--> 653 context))
654
655 if ensure_min_features > 0 and array.ndim == 2:
ValueError: Found array with 0 sample(s) (shape=(0, 1)) while a minimum of 1 is required.
如何解决?