add:ques1 and ques3.1
6
.gitignore
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
.idea/
|
||||
.ipynb_checkpoints/
|
||||
checkpoint/
|
||||
__pycache__/
|
||||
.DS_Store
|
||||
jupyter/
|
Before Width: | Height: | Size: 287 KiB |
Before Width: | Height: | Size: 39 KiB |
Before Width: | Height: | Size: 80 KiB |
Before Width: | Height: | Size: 253 KiB |
@ -3,7 +3,7 @@ import seaborn as sns
|
||||
import matplotlib.pyplot as plt
|
||||
def plot_heatmap(matrix, len, wid, title="Heatmap", save_path="heatmap.png"):
|
||||
# 设置支持中文的字体
|
||||
plt.rcParams['font.family'] = 'SimHei'
|
||||
# plt.rcParams['font.family'] = 'SimHei'
|
||||
|
||||
# 解决负号显示问题
|
||||
plt.rcParams['axes.unicode_minus'] = False
|
||||
|
BIN
images/PCA_cumulative_explained_variance.png
Normal file
After Width: | Height: | Size: 66 KiB |
Before Width: | Height: | Size: 85 KiB After Width: | Height: | Size: 85 KiB |
BIN
images/acf_AQI.png
Normal file
After Width: | Height: | Size: 45 KiB |
BIN
images/acf_CO.png
Normal file
After Width: | Height: | Size: 46 KiB |
BIN
images/acf_NO2.png
Normal file
After Width: | Height: | Size: 47 KiB |
BIN
images/acf_O3.png
Normal file
After Width: | Height: | Size: 47 KiB |
BIN
images/acf_PM10.png
Normal file
After Width: | Height: | Size: 44 KiB |
BIN
images/acf_PM2.5.png
Normal file
After Width: | Height: | Size: 44 KiB |
BIN
images/acf_SO2.png
Normal file
After Width: | Height: | Size: 44 KiB |
BIN
images/all_acf_subplots.png
Normal file
After Width: | Height: | Size: 500 KiB |
BIN
images/components_heatmap.png
Normal file
After Width: | Height: | Size: 89 KiB |
BIN
images/correlation_heatmap.png
Normal file
After Width: | Height: | Size: 317 KiB |
BIN
images/hourly_AQI.png
Normal file
After Width: | Height: | Size: 128 KiB |
BIN
images/hourly_CO.png
Normal file
After Width: | Height: | Size: 141 KiB |
BIN
images/hourly_NO2.png
Normal file
After Width: | Height: | Size: 132 KiB |
BIN
images/hourly_O3.png
Normal file
After Width: | Height: | Size: 128 KiB |
BIN
images/hourly_PM10.png
Normal file
After Width: | Height: | Size: 135 KiB |
BIN
images/hourly_PM2.5.png
Normal file
After Width: | Height: | Size: 121 KiB |
BIN
images/hourly_SO2.png
Normal file
After Width: | Height: | Size: 128 KiB |
BIN
images/hourly_trends_combined.png
Normal file
After Width: | Height: | Size: 316 KiB |
BIN
images/xg_by_step.png
Normal file
After Width: | Height: | Size: 584 KiB |
BIN
images/xg_feature_importance.png
Normal file
After Width: | Height: | Size: 155 KiB |
@ -0,0 +1,65 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"metadata": {},
|
||||
"cell_type": "code",
|
||||
"outputs": [],
|
||||
"execution_count": null,
|
||||
"source": [
|
||||
"\n",
|
||||
"# 绘制各指标小时均值变化趋势(标准化后)折线图\n",
|
||||
"for i, indicator in enumerate(indicators):\n",
|
||||
" plt.plot(normalized.index, normalized[indicator], \n",
|
||||
" marker='o',label=indicator, color=colors[i], linewidth=2)\n",
|
||||
"\n",
|
||||
"plt.title('各指标小时均值变化趋势(标准化后)', fontsize=14)\n",
|
||||
"plt.xlabel('小时', fontsize=12)\n",
|
||||
"plt.ylabel('标准化值', fontsize=12)\n",
|
||||
"plt.xticks(range(0, 24))\n",
|
||||
"plt.grid(alpha=0.3)\n",
|
||||
"plt.legend(bbox_to_anchor=(1.05, 1), loc='upper left')\n",
|
||||
"plt.tight_layout()\n",
|
||||
"\n",
|
||||
"# 新增保存代码\n",
|
||||
"plt.savefig('images/hourly_trends_combined.png', dpi=300, bbox_inches='tight') # 保存组合大图\n",
|
||||
"plt.show()\n",
|
||||
"\n",
|
||||
"# 新增保存子图代码\n",
|
||||
"for i, indicator in enumerate(indicators):\n",
|
||||
" plt.figure(figsize=(8, 5))\n",
|
||||
" plt.plot(normalized.index, normalized[indicator], \n",
|
||||
" marker='o', color=colors[i], linewidth=2)\n",
|
||||
" plt.title(f'{indicator}小时均值变化趋势(标准化后)')\n",
|
||||
" plt.xlabel('小时')\n",
|
||||
" plt.ylabel('标准化值')\n",
|
||||
" plt.xticks(range(0, 24))\n",
|
||||
" plt.grid(alpha=0.3)\n",
|
||||
" plt.tight_layout()\n",
|
||||
" plt.savefig(f'images/hourly_{indicator}.png', dpi=300) # 保存单个指标子图\n",
|
||||
" plt.close()"
|
||||
],
|
||||
"id": "bc314c8f5ab643d4"
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 2
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython2",
|
||||
"version": "2.7.6"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
@ -1,4 +1,21 @@
|
||||
## 热力图解读
|
||||
## 题目1
|
||||
### 结果分析:
|
||||
#### 折线图
|
||||
|
||||
从图中标准化后的空气质量指标小时均值变化趋势可见,各指标在 24 小时时间维度上呈现一定周期性特征:
|
||||
各指标在每日相同时段表现出规律性波动,如部分指标于特定小时(如 19—23 时)出现标准化值峰值,在其他小时(如 4—5 时)形成谷值,且 “波峰 — 波谷” 的波动模式在每日 24 小时周期内稳定重复。这种以自然日为单位、在相同日时段内可重复的规律性变化,一定程度上体现了空气质量指标小时均值以 24 小时为周期的周期性特征,反映出其变化遵循固定时间循环规律。
|
||||
|
||||
#### ACF图
|
||||
|
||||
1. 在 O3 ACF 图中,自相关系数呈现规律性波动:滞后 24 小时、48 小时、72 小时处多次显著超出置信区间(阴影区域),形成明显峰值,且峰值间隔固定为 24 小时。这直接表明 O3 指标的小时均值变化存在 24 小时周期性,即数据以自然日为周期循环波动,符合 “日周期” 特征。
|
||||
|
||||
2. NO2 ACF 图中,自相关系数出现一定起伏波动,尤其在滞后 12 小时、24 小时等间隔处,呈现相对规律的波动趋势。尽管规律性弱于 O3,仍暗示 NO2 指标可能存在周期性,需结合其他分析进一步验证。
|
||||
|
||||
3. AQI、PM2.5、PM10、CO、SO2 的 ACF 图中,自相关系数随滞后小时数增加逐渐衰减,未出现如 O3 般规律的周期性峰值,也无固定间隔的显著波动,说明这些指标在 72 小时滞后范围内,周期性特征不明显。
|
||||
|
||||
## 题目2
|
||||
|
||||
### 热力图解读
|
||||
热力图显示了各指标之间的相关性。颜色越深表示相关性越强,颜色越浅表示相关性越弱,偏红色表示正相关,偏蓝色表示负相关。
|
||||
1. 图形大致可分为四个部分:
|
||||
- 左上角的颜色较深的矩形反映了AQI与数个观测指标(污染物)的关系。
|
||||
@ -7,7 +24,7 @@
|
||||
- 右下角的颜色较深的矩形主要反映各环境指标间的相关关系。
|
||||
2. 空气质量指数(AQI)与PM2.5、PM10有很强正相关关系,与CO、NO2、SO2呈现较强正相关关系。同时跟VV(水平能见度)有较强负相关关系。后者的原因显然。经过查阅资料,前者数个指标本就为AQI的计算所考虑的指标,而同为考虑指标的O3相关性低,不知道为什么,需要进一步调研。
|
||||
3. 小时(hour)与O3等指标呈现一定正相关关系,这或许反映O3浓度变化具有日周期。且与U(地面高度2米处的相对湿度)等指标呈现一定负相关关系。
|
||||
## 主成分分析解读
|
||||
### 主成分分析解读
|
||||
1. 检验指标:
|
||||
- KMO值: 0.762>0.7。
|
||||
- 巴赫利特检验卡方值: 90424.712, p值: 0.0,显著。
|
||||
@ -42,7 +59,10 @@
|
||||
6) 交叉载荷与特殊变量
|
||||
- O3(臭氧):在Factor1和Factor3上均有载荷,可能需结合气象与化学机制进一步分析。
|
||||
- VV(能见度):受Factor3(风速)和Factor2(颗粒物)共同影响,符合实际物理规律。
|
||||
## XGBOOST模型解读
|
||||
|
||||
## 题目3
|
||||
|
||||
### XGBOOST模型解读
|
||||
1. 该模型使用历史AQI数据,并进行周期性编码和滞后特征构建(3小时粒度的滞后特征(最多7天)),作为特征工程。
|
||||
2. 每次预测均采用该时间点以前的真实数据,即每次预测均为单步预测。
|
||||
3. 使用随机搜索法参数调优。
|
||||
@ -51,4 +71,4 @@
|
||||
- R-squared: 0.92
|
||||
- MAE: 7.87
|
||||
5. 重要特征:观察图,AQI_lag_1,2,3最为重要,即该时刻的AQI主要由前3个观测时刻决定。day_of_week显示影响较小,但不是完全没有。
|
||||
6. 其实也做了利用递归直接预测一整个月的,
|
||||
6. 其实也做了利用递归直接预测一整个月的,效果看图就很明了了
|