赞
踩
DL之TCN:基于keras框架利用一维时间卷积网络TCN算法(Conv1D+Flatten+Dense)对上海最高气温实现回归预测(把时间序列数据集转化为有监督学习数据集)案例
目录
利用时间卷积网络TCN算法对上海最高气温实现回归预测(把时间序列数据集转化为有监督学习数据集)案例
相关文章
Keras之TCN:基于keras框架利用时间卷积网络TCN算法对上海最高气温实现回归预测(把时间序列数据集转化为有监督学习数据集)案例
Keras之TCN:基于keras框架利用时间卷积网络TCN算法对上海最高气温实现回归预测(把时间序列数据集转化为有监督学习数据集)案例实现代码
date | week | max_temperature | min_temperature | weather | wind_direction | wind_level | air_quality_index | air_quality_level |
2021/1/1 | 周五 | 4 | -1 | 晴~多云 | 西北风 | 2级 | 52 | 良 |
2021/1/2 | 周六 | 7 | 1 | 晴~多云 | 东北风 | 2级 | 69 | 良 |
2021/1/3 | 周日 | 10 | 6 | 阴 | 东北风 | 2级 | 66 | 良 |
2021/1/4 | 周一 | 13 | 7 | 阴 | 东风 | 2级 | 44 | 优 |
2021/1/5 | 周二 | 8 | 2 | 阴~多云 | 东北风 | 3级 | 49 | 优 |
2021/1/6 | 周三 | 5 | -4 | 阴 | 北风 | 3级 | 46 | 优 |
2021/1/7 | 周四 | -3 | -6 | 阴 | 西北风 | 4级 | 67 | 良 |
2021/1/8 | 周五 | -1 | -5 | 阴~晴 | 西北风 | 3级 | 50 | 优 |
2021/1/9 | 周六 | 3 | -1 | 晴~多云 | 西北风 | 3级 | 57 | 良 |
2021/1/10 | 周日 | 5 | -1 | 阴~多云 | 西北风 | 2级 | 73 | 良 |
- <class 'pandas.core.frame.DataFrame'>
- DatetimeIndex: 805 entries, 2021-01-01 to 2023-03-16
- Data columns (total 8 columns):
- # Column Non-Null Count Dtype
- --- ------ -------------- -----
- 0 week 805 non-null object
- 1 max_temperature 805 non-null int64
- 2 min_temperature 805 non-null int64
- 3 weather 805 non-null object
- 4 wind_direction 805 non-null object
- 5 wind_level 805 non-null object
- 6 air_quality_index 667 non-null float64
- 7 air_quality_level 775 non-null object
- dtypes: float64(1), int64(2), object(5)
- memory usage: 56.6+ KB
- None
- week max_temperature ... air_quality_index air_quality_level
- date ...
- 2021-01-01 周五 4 ... 52.0 良
- 2021-01-02 周六 7 ... 69.0 良
- 2021-01-03 周日 10 ... 66.0 良
- 2021-01-04 周一 13 ... 44.0 优
- 2021-01-05 周二 8 ... 49.0 优
- ... ... ... ... ... ...
- 2023-03-12 周日 12 ... 68.0 良
- 2023-03-13 周一 14 ... 52.0 良
- 2023-03-14 周二 20 ... 55.0 良
- 2023-03-15 周三 23 ... 52.0 良
- 2023-03-16 周四 15 ... 69.0 良
-
- [805 rows x 8 columns]
- df_train (725,)
- df_test (80,)
- train_supervised (684, 42)
- test_supervised (39, 42)
- train_supervised [[ 4. 7. 10. ... 11. 12. 10.]
- [ 7. 10. 13. ... 12. 10. 13.]
- [10. 13. 8. ... 10. 13. 17.]
- ...
- [15. 13. 16. ... 6. 4. 5.]
- [13. 16. 18. ... 4. 5. 6.]
- [16. 18. 17. ... 5. 6. 7.]]
- Epoch 1/1000
- 43/43 - 1s - loss: 124.9150 - val_loss: 28.0470 - 764ms/epoch - 18ms/step
- Epoch 2/1000
- 43/43 - 0s - loss: 41.9717 - val_loss: 41.4632 - 100ms/epoch - 2ms/step
- Epoch 3/1000
- 43/43 - 0s - loss: 55.0186 - val_loss: 36.8242 - 92ms/epoch - 2ms/step
- Epoch 4/1000
- 43/43 - 0s - loss: 48.0289 - val_loss: 35.4341 - 105ms/epoch - 2ms/step
- Epoch 5/1000
- 43/43 - 0s - loss: 46.5520 - val_loss: 34.2107 - 97ms/epoch - 2ms/step
- Epoch 6/1000
- 43/43 - 0s - loss: 39.3062 - val_loss: 34.9127 - 98ms/epoch - 2ms/step
- Epoch 7/1000
- 43/43 - 0s - loss: 41.5857 - val_loss: 33.3312 - 102ms/epoch - 2ms/step
- Epoch 8/1000
- 43/43 - 0s - loss: 39.6624 - val_loss: 36.8456 - 89ms/epoch - 2ms/step
- Epoch 9/1000
- 43/43 - 0s - loss: 37.2232 - val_loss: 32.2082 - 78ms/epoch - 2ms/step
- Epoch 10/1000
- 43/43 - 0s - loss: 32.3461 - val_loss: 32.3342 - 81ms/epoch - 2ms/step
- Epoch 11/1000
- 43/43 - 0s - loss: 32.4692 - val_loss: 31.6105 - 87ms/epoch - 2ms/step
- Epoch 12/1000
- 43/43 - 0s - loss: 31.0049 - val_loss: 31.7516 - 85ms/epoch - 2ms/step
- Epoch 13/1000
- 43/43 - 0s - loss: 31.4120 - val_loss: 32.4814 - 94ms/epoch - 2ms/step
- Epoch 14/1000
- 43/43 - 0s - loss: 30.3727 - val_loss: 32.3661 - 172ms/epoch - 4ms/step
- Epoch 15/1000
- 43/43 - 0s - loss: 28.5779 - val_loss: 33.0914 - 104ms/epoch - 2ms/step
- Epoch 16/1000
- 43/43 - 0s - loss: 28.2869 - val_loss: 33.0207 - 96ms/epoch - 2ms/step
- Epoch 17/1000
- 43/43 - 0s - loss: 27.9438 - val_loss: 33.5665 - 96ms/epoch - 2ms/step
- Epoch 18/1000
- 43/43 - 0s - loss: 26.8220 - val_loss: 34.3124 - 108ms/epoch - 3ms/step
- Epoch 19/1000
- 43/43 - 0s - loss: 26.4627 - val_loss: 34.0599 - 95ms/epoch - 2ms/step
- Epoch 20/1000
- 43/43 - 0s - loss: 26.7424 - val_loss: 34.9252 - 91ms/epoch - 2ms/step
- Epoch 21/1000
- 43/43 - 0s - loss: 25.3610 - val_loss: 35.1354 - 104ms/epoch - 2ms/step
- Epoch 22/1000
- 43/43 - 0s - loss: 25.3079 - val_loss: 36.1249 - 97ms/epoch - 2ms/step
- Epoch 23/1000
- 43/43 - 0s - loss: 24.5994 - val_loss: 36.0049 - 93ms/epoch - 2ms/step
- Epoch 24/1000
- 43/43 - 0s - loss: 24.4569 - val_loss: 36.4239 - 105ms/epoch - 2ms/step
- Epoch 25/1000
- 43/43 - 0s - loss: 23.9317 - val_loss: 35.9488 - 93ms/epoch - 2ms/step
- Epoch 26/1000
- 43/43 - 0s - loss: 23.4671 - val_loss: 36.1248 - 87ms/epoch - 2ms/step
- Epoch 27/1000
- 43/43 - 0s - loss: 23.2060 - val_loss: 36.7490 - 85ms/epoch - 2ms/step
- Epoch 28/1000
- 43/43 - 0s - loss: 23.0000 - val_loss: 36.9432 - 74ms/epoch - 2ms/step
- Epoch 29/1000
- 43/43 - 0s - loss: 22.9452 - val_loss: 37.4504 - 69ms/epoch - 2ms/step
- Epoch 30/1000
- 43/43 - 0s - loss: 22.1462 - val_loss: 38.7905 - 70ms/epoch - 2ms/step
- Epoch 31/1000
- 43/43 - 0s - loss: 22.0330 - val_loss: 38.7575 - 103ms/epoch - 2ms/step
- Epoch 32/1000
- 43/43 - 0s - loss: 22.0065 - val_loss: 38.2103 - 84ms/epoch - 2ms/step
- Epoch 33/1000
- 43/43 - 0s - loss: 21.5495 - val_loss: 39.7773 - 98ms/epoch - 2ms/step
- Epoch 34/1000
- 43/43 - 0s - loss: 21.3134 - val_loss: 40.6234 - 106ms/epoch - 2ms/step
- Epoch 35/1000
- 43/43 - 0s - loss: 20.8954 - val_loss: 41.8935 - 91ms/epoch - 2ms/step
- Epoch 36/1000
- 43/43 - 0s - loss: 20.6854 - val_loss: 42.6756 - 98ms/epoch - 2ms/step
- Epoch 37/1000
- 43/43 - 0s - loss: 20.6962 - val_loss: 44.5400 - 102ms/epoch - 2ms/step
- Epoch 38/1000
- 43/43 - 0s - loss: 20.2958 - val_loss: 43.9005 - 83ms/epoch - 2ms/step
- Epoch 39/1000
- 43/43 - 0s - loss: 20.0900 - val_loss: 46.3218 - 80ms/epoch - 2ms/step
- Epoch 40/1000
- 43/43 - 0s - loss: 19.8518 - val_loss: 47.3231 - 104ms/epoch - 2ms/step
- Epoch 41/1000
- 43/43 - 0s - loss: 19.7069 - val_loss: 48.0385 - 100ms/epoch - 2ms/step
- Epoch 42/1000
- 43/43 - 0s - loss: 19.4992 - val_loss: 50.7614 - 97ms/epoch - 2ms/step
- Epoch 43/1000
- 43/43 - 0s - loss: 19.1684 - val_loss: 49.1486 - 105ms/epoch - 2ms/step
- Epoch 44/1000
- 43/43 - 0s - loss: 19.0760 - val_loss: 53.2720 - 99ms/epoch - 2ms/step
- Epoch 45/1000
- 43/43 - 0s - loss: 18.9300 - val_loss: 50.1390 - 100ms/epoch - 2ms/step
- Epoch 46/1000
- 43/43 - 0s - loss: 18.8669 - val_loss: 54.0359 - 106ms/epoch - 2ms/step
- Epoch 47/1000
- 43/43 - 0s - loss: 18.6694 - val_loss: 52.4647 - 95ms/epoch - 2ms/step
- Epoch 48/1000
- 43/43 - 0s - loss: 18.5207 - val_loss: 55.3733 - 97ms/epoch - 2ms/step
- Epoch 49/1000
- 43/43 - 0s - loss: 18.2313 - val_loss: 54.8835 - 106ms/epoch - 2ms/step
- Epoch 50/1000
- 43/43 - 0s - loss: 18.1582 - val_loss: 53.5451 - 100ms/epoch - 2ms/step
-
- ……………………
-
- 43/43 - 0s - loss: 1.2712 - val_loss: 151.7615 - 95ms/epoch - 2ms/step
- Epoch 993/1000
- 43/43 - 0s - loss: 1.1109 - val_loss: 153.4365 - 90ms/epoch - 2ms/step
- Epoch 994/1000
- 43/43 - 0s - loss: 1.2277 - val_loss: 154.8537 - 135ms/epoch - 3ms/step
- Epoch 995/1000
- 43/43 - 0s - loss: 1.1820 - val_loss: 154.8023 - 202ms/epoch - 5ms/step
- Epoch 996/1000
- 43/43 - 0s - loss: 1.5359 - val_loss: 153.2385 - 195ms/epoch - 5ms/step
- Epoch 997/1000
- 43/43 - 0s - loss: 1.6835 - val_loss: 154.5790 - 212ms/epoch - 5ms/step
- Epoch 998/1000
- 43/43 - 0s - loss: 2.7265 - val_loss: 149.3467 - 197ms/epoch - 5ms/step
- Epoch 999/1000
- 43/43 - 0s - loss: 3.3956 - val_loss: 158.7523 - 179ms/epoch - 4ms/step
- Epoch 1000/1000
- 43/43 - 0s - loss: 6.5273 - val_loss: 141.5004 - 180ms/epoch - 4ms/step
- y_val y_val_pred
- 0 18.0 14.574027
- 1 23.0 9.982560
- 2 23.0 11.338496
- 3 24.0 10.234162
- 4 25.0 16.762114
- 5 27.0 9.477368
- 6 22.0 -0.121278
- 7 12.0 19.867815
- 8 14.0 22.165188
- 9 20.0 22.839424
- 10 23.0 20.204948
- 11 15.0 16.035151
- weather_shanghai_2000_val_MAE: 9.371264984210333
- weather_shanghai_2000_val_MSE: 126.371276982466
- weather_shanghai_2000_val_RMSE: 11.241497986588175
- weather_shanghai_2000_val_R2: -5.1394952380145424
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。