C:\Users\马斌\Desktop\NGSIM_data_processing\80s\lstmtest.py:31: MatplotlibDeprecationWarning: Support for FigureCanvases without a required_interactive_framework attribute was deprecated in Matplotlib 3.6 and will be removed two minor releases later. plt.plot(history.history['loss']) C:\Users\马斌\Desktop\NGSIM_data_processing\80s\lstmtest.py:37: MatplotlibDeprecationWarning: Support for FigureCanvases without a required_interactive_framework attribute was deprecated in Matplotlib 3.6 and will be removed two minor releases later. plt.show() 20/20 [==============================] - 0s 832us/step 9/9 [==============================] - 0s 0s/step Traceback (most recent call last): File "C:\Users\马斌\Desktop\NGSIM_data_processing\80s\lstmtest.py", line 42, in <module> train_predict = scaler.inverse_transform(train_predict) File "D:\python\python3.9.5\pythonProject\venv\lib\site-packages\sklearn\preprocessing\_data.py", line 541, in inverse_transform X -= self.min_ ValueError: non-broadcastable output operand with shape (611,1) doesn't match the broadcast shape (611,2)
时间: 2023-07-25 13:03:28 浏览: 111
《时代的变换》互联网构建新世界读书笔记PPT模板.pptx
这个错误的原因是在进行逆变换时,输入的数组的形状与原始数据的形状不匹配。具体来说,你的 `train_predict` 数组的形状为 `(611, 1)`,而 `scaler.inverse_transform()` 函数期望的形状是 `(611, 2)`。这可能是因为你在训练模型时只使用了单个特征,但是在进行预测时却使用了多个特征。
你可以检查一下在训练模型时使用的特征数量是否与进行预测时使用的特征数量一致。如果不一致,你需要在进行预测时只使用与训练模型时相同的特征。如果特征数量相同,那么可能是在数据处理的过程中出现了错误,你需要仔细检查数据的形状和处理方法。
阅读全文