登录
首页 > 编程 > Matlab决策树对空气质量和天气温度及天气数据做交通出行推荐预测|附代码数据

Matlab决策树对空气质量和天气温度及天气数据做交通出行推荐预测|附代码数据

发布时间:2023-08-13 20:52:45 发布用户: admin

最近我们被客户要求撰写关于决策树的研究报告,包括一些图形和统计输出。

为解决城市交通拥堵问题,本文提出了一种基于 Matlab决策树的交通预测方法,我们通过采集上海地区的空气质量数据和温度数据,帮助客户在 Matlab中实现决策树建模,利用所提取的天气和温度特征建立决策树,对未来的出行时间、出行路线等进行预测。结果表明:该方法可实现交通时间、出行路线的预测,并能在未来三天进行有效预测时间长度与空气质量、温度相关。

数据
里面一个是天气数据(区县自动站实况数据),只把地区为徐家汇的取出来,其余地点的不用参考。

另一个是空气数据(实时空气质量数据)。

 

 

预期结果
根据空气中的空气质量和天气数据中的温度及天气情况做一个交通出行的推荐。

举个例子: 今天温度0度 天气晴朗 空气质量优 出行方式可以为 公交车或地铁。

今天温度15度 天气晴朗 空气质量优 出行方式为 步行。

今天温度15度 天气晴朗 控制质量轻度污染 出现方式为 公交车或地铁。

读取气温数据
 

 

[data, ~, raw] = xlsread('区县自动站实况数据.xlsx','Sheet2');
1.
筛选对应日期数据
 

 

data=data(1:9649,:);
raw=raw(1:9649,:);
1.
2.
找出徐家汇地区的数据
 

 

index=strcmp(raw(:,3),'徐家汇')
1.
读取空气质量数据
 

 

[data2, ~, raw2, dateNums] = xlsread('实时空气质量数据(历史)2.xlsx','Sheet1','','
1.
筛选对应日期数据
 

 

data2=data2(4415:end,:);
raw2=raw2(4415:end,:);
1.
2.
得到对应时间
 

 

index=1:3:2880
1.
得到对应时间的 空气质量数据

 

 

mydata=[raw,raw2];
1.
建立决策规则
分类类别号

 

 

label=mydata(:,18);
%label=label(2:end);
1.
2.
将类别号赋值给outData

 

 

outData=label;
1.
获得特征变量矩阵

 

 

inData = [data,data2];                    % 输入特征矩阵
1.
根据训练集数据创建决策树

 

 

classregtree(inData, o)
1.
查看决策树

 

 

view(mytree);
1.


决策树规则
 

 

Decision tree for classification

  1  if x5<11.5 then node 2 elseif x5>=11.5 then node 3 else 步行

  2  if x5<3.5 then node 4 elseif x5>=3.5 then node 5 else 步行

  3  if x13<0.45 then node 6 elseif x13>=0.45 then node 7 else 步行

  4  if x1<2.01504e+011 then node 8 elseif x1>=2.01504e+011 then node 9 else 公交车或地铁

  5  if x12<91.5 then node 10 elseif x12>=91.5 then node 11 else 步行

  6  if x11<11.5 then node 12 elseif x11>=11.5 then node 13 else 步行

  7  if x9<27.5 then node 14 elseif x9>=27.5 then node 15 else 公交车或地铁

  8  if x6<1.6 then node 16 elseif x6>=1.6 then node 17 else 公交车或地铁

  9  class = 步行

 10  if x8<86.5 then node 18 elseif x8>=86.5 then node 19 else 步行

 11  class = 公交车或地铁

 12  if x7<1.5 then node 20 elseif x7>=1.5 then node 21 else 步行

 13  if x9<94 then node 22 elseif x9>=94 then node 23 else 公交车或地铁

 14  if x9<8.5 then node 24 elseif x9>=8.5 then node 25 else 步行

 15  if x6<2.75 then node 26 elseif x6>=2.75 then node 27 else 公交车或地铁

 16  class = 公交车或地铁

 17  class = 步行

 18  class = 步行

 19  if x1<2.01502e+011 then node 28 elseif x1>=2.01502e+011 then node 29 else 步行

 20  class = 步行

 21  if x1<2.01504e+011 then node 30 elseif x1>=2.01504e+011 then node 31 else 步行

 22  if x4<6.95 then node 32 elseif x4>=6.95 then node 33 else 公交车或地铁

 23  class = 步行

 24  if x6<0.35 then node 34 elseif x6>=0.35 then node 35 else 公交车或地铁

 25  if x8<49.5 then node 36 elseif x8>=49.5 then node 37 else 步行

 26  if x6<2.25 then node 38 elseif x6>=2.25 then node 39 else 公交车或地铁

 27  if x11<26.5 then node 40 elseif x11>=26.5 then node 41 else 步行

 28  class = 步行

 29  class = 公交车或地铁

 30  class = 步行

 31  class = 公交车或地铁

 32  if x5<142.5 then node 42 elseif x5>=142.5 then node 43 else 步行

 33  class = 公交车或地铁

 34  class = 步行

 35  if x5<311 then node 44 elseif x5>=311 then node 45 else 公交车或地铁

 36  if x9<22 then node 46 elseif x9>=22 then node 47 else 公交车或地铁

 37  if x12<135 then node 48 elseif x12>=135 then node 49 else 步行

 38  if x5<102.5 then node 50 elseif x5>=102.5 then node 51 else 公交车或地铁

 39  if x8<18.5 then node 52 elseif x8>=18.5 then node 53 else 公交车或地铁

 40  if x12<40.5 then node 54 elseif x12>=40.5 then node 55 else 步行

 41  if x6<3 then node 56 elseif x6>=3 then node 57 else 公交车或地铁

 42  class = 步行

 43  if x1<2.01503e+011 then node 58 elseif x1>=2.01503e+011 then node 59 else 公交车或地铁

 44  class = 公交车或地铁

 45  class = 步行

 46  if x4<21.75 then node 60 elseif x4>=21.75 then node 61 else 公交车或地铁

 47  if x14<40.5 then node 62 elseif x14>=40.5 then node 63 else 步行

 48  if x12<78.5 then node 64 elseif x12>=78.5 then node 65 else 步行

 49  if x5<212 then node 66 elseif x5>=212 then node 67 else 公交车或地铁

 50  if x14<35.5 then node 68 elseif x14>=35.5 then node 69 else 公交车或地铁

 51  if x6<1.85 then node 70 elseif x6>=1.85 then node 71 else 步行

 52  class = 公交车或地铁
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
96.
97.
98.
99.
100.
101.
102.
103.
104.
105.
查看所有预测的分类标签

 

 

y_est

type classregtree
1.
2.
3.
判断准确率

 

 

Remp
1.
气温

 

 

hist(inData(:,4))
1.


风向

 

 

hist(inData(:,5))
1.

 

PHP更多>>

海关总署:我国进出口 连续2个月同比增长 长清区成功举办首届职工家政技能大赛 前妻要回土地于法有据 法院公允分割定分止争 G312线傅苦公路5标项目全幅顺利贯通 实现“56到84+”延伸,这个镇的文化中心为更多人群提供公共文化服务! 前11个月进出口持平 11月份同比增长1.2% 中国与新加坡签署中新自由贸易协定进一步升级议定书 凤阳奋力绘就宜居宜业和美乡村新画卷 浙江持续擦亮“一路先行”党建品牌 山东兖州:“一线支部工作法”将党旗插在田间地头 固安县加快推进 空天信息产业发展 王晓涛被开除党籍 濮阳王瑞林获评中国青年志愿者优秀个人 报中共中央批准,两“虎”同时受处分! 国务院:支持上海自贸试验区可信、安全和负责任地使用人工智能技术 把“东方美”传向国际市场!聊城这家小镇企业东盟市占率超70% 交通运输部关于发布《综合货运枢纽设计规范》等18项交通运输行业标准的公告 喜讯 | 贵州三力荣获“2021-2023年贵州省促进新型工业化发展先进企业”称号 内蒙古这起“百万黄金被盗案”,更多细节披露! 交通运输部印发《城市轨道交通通信系统运营技术规范(试行)》 黑龙江省政协原副主席曲敏,被“双开” 中老铁路磨憨口岸出入境人员突破10万人次 甘肃兰州榆中县:设立“零工驿站”提供就业服务 扶余:抢抓战略机遇,推动县域经济高质量发展 【“双争”进行时】霸州:百姓宣讲家乡事 强国复兴攀高峰 “山西一女性公职人员实名举报两任局长”,最新通报 海关总署:11月我国外贸进出口同比增长1.2% (人权行动看中国)河南驻马店:特色种植产业成农民增收好渠道 总投资74亿元!中国铁建中标海南临高金牌港开发区港口及配套工程项目 鼓励大学生基层就业还需多方向着力
Copyright 2018-2023 黑鸟云 版权所有  京ICP备2022032575号-3