当前位置:   article > 正文

计算机毕业设Python+Spark智慧城市交通大数据 交通流量预测 交通爬虫 地铁客流量分析 大数据毕业设计 大数据毕设 深度学习 机器学习 人工智能 知识图谱_基于spark的智慧交通

基于spark的智慧交通

西安工程大学本科毕业设计(论文)开题报告

学院:计算机科学学院    专业:               填表时间:2023年3月28日

姓  名

班级

学号

题  目

基于大数据的地铁交通客流量预测系统的设计与实现

选题的意义:

随着城市化进程的加快和人口的不断增长,地铁作为城市主要的一种主要交通工具,凭着其准时性、抗灾性等优越性能,越来越受到广大乘客的青睐。但是由于地铁站有着特殊的运营环境,其内的空间有限,客容量也就随之受到限制,因此,对进入地铁站点的乘客来说,在节假日、上下班高峰、气候恶劣变化、周围出现突发事件等情况下,过多的乘客涌入地铁站内,不仅对会乘客的候车时间造成延误,而且还有可能对乘客在地铁站内的安全造成威胁。所以合理预测地铁客流量对于优化地铁运营、提高乘客出行体验具有重要意义。客流量预测系统可以为地铁公司提供决策支持,以便灵活调整运营策略和资源配置,从而实现更高效的地铁运营管理。本设计将以地铁为研究对象,设计和实现基于大数据的地铁客流量预测系统,旨在提升地铁运营效率,改善乘客出行体验。

研究综述:

现如今,中长期客流预测技术在我国的宏观调控中起着举足轻重的作用。但随着研究的深入发展,中长期客流预测技术发展已经趋于平缓、很难在短时间再取得技术上的重大 突破,越来越多的学者由此开始把注意力放到了短时客流预测上。与中长期客流预测相比,短期客流预测具有更短的时间粒度、更庞大的数据量和更多的细节需求,且预测模型方法尚不完善,相关研究成果较少,大多数都是针对某一具体路段的车流量进行预测。如今随着数据时代的到来,出行数据的收集与处理越来越简单并专业化,大量的数据使城市轨道交通的短期客流预测逐渐增多。

论文(设计)写作提纲:

本文主要对地铁数据,进行分析,系统技术主要功能有:

  1. 对原始数据集进行预处理;2.使用python语言编写Spark程序对HDFS中的数据进行处理分析,并把分析结果写入到MySQL数据库;3.利用pyeharts进行前端可视化分析。

用户查看可视化效果,而管理员在后端负责管理,理员功能包含,个人信息,地铁数据,其中地铁数据包含,出行高峰期的10个时间段,地铁限流的10个时间段,地铁限流的前10个站点,人流量随时间的变化趋势预测预测分析,用户管理。用户登录注册,用户查看地铁数据,包含地铁站点数据,地铁热词词云图展示,地铁限流浪饼型图分析前10个站点,地铁限流柱状图分析10个时间段。

研究工作进度安排:

(根据学校安排自行修改)

1、查阅资料,拟定写作大纲,完成研究内容、现状、方法的研究等,提交开题报告;

2、基本完成毕业设计及毕业论文草稿的撰写;

3、提交中期检查相关资料,参加中期检查;

4、修改完善毕业设计,完成毕业设计和论文稿的撰写;

5、提交答辩申请,参加答辩;

6、提交论文最终稿,打印装订论文,整理并上交全套毕业论文(设计)资料。

参考文献目录:

  1. 杨信丰,刘兰芬.基于 AP 聚类的支持向量机公交站点短时客流预测[J],武汉理工大学学报(交通科学与工程版),2020,40(01):36-40.
  2. 王臻,张兴强.基于 ARIMA-FNN 的道路交通事故最优加权组合预测模型[J].交通信息与安全,2020,28(03):89-92.
  3.  李洪嘉,姚红光,李思睿,等.基于灰色-神经网络的虹桥综合交通枢纽客流预测[J].科学技术创新,2020(36):121-122.
  4.  潘亮.基于 EEMD-GSVM 的高速铁路短期客流预测[D].北京交通大学,2020.
  5. 基于深度神经网络的地铁客流预测系统研究[D]. 张琳.北京交通大学 2020
  6. 基于深度学习模型的城市轨道交通短时客流预测方法研究[D]. 王佳琳.北京交通大学 2020
  7. 基于CNN-LSTM组合模型的城市轨道交通短时客流预测研究[D]. 冯碧玉.华东交通大学 2020

指导教师意见:

                                          签名:

                                            2023年3月 29日

教研室主任意见:

                                          签名:

                                             2023年3 月29日

核心算法代码分享如下:

  1. package com.metroData;
  2. import org.apache.flink.configuration.Configuration;
  3. import org.apache.flink.table.api.EnvironmentSettings;
  4. import org.apache.flink.table.api.TableEnvironment;
  5. /**
  6. * 数据查询语言DQL,select操作
  7. * 数据操纵语言DML,insert delete update操作
  8. * 数据定义语言DDL,创建表、视图、索引等操作
  9. * 数据控制语言DCL,赋权、回滚、提交等操作
  10. */
  11. // 先有原始数据Source 对数据进行处理 trans 将处理好的数据发送到mysql sink
  12. public class RealtimeAnalysis {
  13. public static void main(String[] args) throws InterruptedException {
  14. // 执行环境
  15. EnvironmentSettings settings = EnvironmentSettings.newInstance().inStreamingMode().build();
  16. TableEnvironment tableEnv= TableEnvironment.create(settings);
  17. // FlinkSQL 数据Sink到Mysql时,非空存在null值,插入mysql报错,配置下面的参数进行解决:
  18. Configuration configuration = tableEnv.getConfig().getConfiguration();
  19. configuration.setString("table.exec.sink.not-null-enforcer","drop");
  20. // 创建source表
  21. String kafkaSource = "CREATE TABLE MetroSwipingData (\n" +
  22. " card_no VARCHAR,\n" +
  23. " deal_date VARCHAR,\n" +
  24. " deal_type VARCHAR,\n" +
  25. " deal_money DECIMAL(16,2),\n" +
  26. " deal_value DECIMAL(16,2),\n" +
  27. " equ_no VARCHAR,\n" +
  28. " company_name VARCHAR,\n" +
  29. " station VARCHAR,\n" +
  30. " car_no VARCHAR,\n" +
  31. " conn_mark VARCHAR,\n" +
  32. " close_date VARCHAR\n" +
  33. ") WITH (\n" +
  34. " 'connector' = 'kafka',\n" +
  35. " 'topic' = 'MetroSwipingData',\n" +
  36. " 'properties.bootstrap.servers' = 'bigdata:9092',\n" +
  37. " 'properties.group.id' = 'testGroup123',\n" +
  38. " 'scan.startup.mode' = 'earliest-offset',\n" +
  39. " 'format' = 'json',\n" +
  40. " 'json.fail-on-missing-field' = 'false',\n" +
  41. " 'json.ignore-parse-errors' = 'true'\n" +
  42. ")";
  43. // sink测试打印到控制台
  44. String sinkPrint = "CREATE TABLE sinkPrint (\n" +
  45. " station STRING,\n" +
  46. " amount DECIMAL(16,2)\n" +
  47. ") WITH (\n" +
  48. " 'connector' = 'print'\n" +
  49. ")";
  50. // 创建Sink表,连接到MySQL,每个站的累计营收额
  51. String sink_station_amount = "CREATE TABLE station_amount (\n" +
  52. " station STRING,\n" +
  53. " amount DECIMAL(16,2),\n" +
  54. " PRIMARY KEY (station) NOT ENFORCED\n" +
  55. ") WITH (\n" +
  56. " 'connector' = 'jdbc',\n" +
  57. " 'url' = 'jdbc:mysql://bigdata:3306/report?useSSL=false&useUnicode=true&characterEncoding=utf-8',\n" +
  58. " 'table-name' = 'station_amount',\n" +
  59. " 'username' = 'root',\n" +
  60. " 'password' = '123456',\n" +
  61. " 'connection.max-retry-timeout' = '60s',\n" +
  62. " 'sink.max-retries' = '3',\n" +
  63. " 'lookup.max-retries' = '3'\n" +
  64. ")";
  65. // 创建Sink表,连接到MySQL,每个站的出入站人数
  66. String sink_station_peopleNum = "CREATE TABLE station_peopleNum ( \n" +
  67. "station STRING, \n" +
  68. "enterNum INT, \n" +
  69. "outNum INT, \n" +
  70. "PRIMARY KEY (station) NOT ENFORCED \n" +
  71. ") WITH ( \n" +
  72. "'connector' = 'jdbc', \n" +
  73. "'url' = 'jdbc:mysql://bigdata:3306/report?useSSL=false&useUnicode=true&characterEncoding=utf-8', \n" +
  74. "'table-name' = 'station_peopleNum', \n" +
  75. "'username' = 'root', \n" +
  76. "'password' = '123456', \n" +
  77. "'connection.max-retry-timeout' = '60s', \n" +
  78. "'sink.max-retries' = '3', \n" +
  79. "'lookup.max-retries' = '3' \n" +
  80. ")";
  81. // 创建Sink表,连接到MySQL,每条线路的营收额
  82. String sink_line_amount = "CREATE TABLE line_amount ( \n" +
  83. "line STRING, \n" +
  84. "amount DECIMAL(16,2),\n" +
  85. "PRIMARY KEY (line) NOT ENFORCED \n" +
  86. ") WITH ( \n" +
  87. "'connector' = 'jdbc', \n" +
  88. "'url' = 'jdbc:mysql://bigdata:3306/report?useSSL=false&useUnicode=true&characterEncoding=utf-8', \n" +
  89. "'table-name' = 'line_amount', \n" +
  90. "'username' = 'root', \n" +
  91. "'password' = '123456', \n" +
  92. "'connection.max-retry-timeout' = '60s', \n" +
  93. "'sink.max-retries' = '3', \n" +
  94. "'lookup.max-retries' = '3' \n" +
  95. ")";
  96. // 创建Sink表,连接到MySQL,每天的客运量
  97. // String sink_data_peopleNum = "CREATE TABLE data_peopleNum ( \n" +
  98. // "dt STRING, \n" +
  99. // "peopleNum BIGINT,\n" +
  100. // "PRIMARY KEY (dt) NOT ENFORCED \n" +
  101. // ") WITH ( \n" +
  102. // "'connector' = 'jdbc', \n" +
  103. // "'url' = 'jdbc:mysql://bigdata:3306/report?useSSL=false&useUnicode=true&characterEncoding=utf-8', \n" +
  104. // "'table-name' = 'data_peopleNum', \n" +
  105. // "'username' = 'root', \n" +
  106. // "'password' = '123456', \n" +
  107. // "'connection.max-retry-timeout' = '60s', \n" +
  108. // "'sink.max-retries' = '3', \n" +
  109. // "'lookup.max-retries' = '3' \n" +
  110. // ")";
  111. // 创建Sink表,连接到MySQL,累计营收额
  112. String sink_total_amount = "CREATE TABLE total_amount ( \n" +
  113. "id INT,\n" +
  114. "total_amount DECIMAL(16,2),\n" +
  115. "PRIMARY KEY (id) NOT ENFORCED \n" +
  116. ") WITH ( \n" +
  117. "'connector' = 'jdbc', \n" +
  118. "'url' = 'jdbc:mysql://bigdata:3306/report?useSSL=false&useUnicode=true&characterEncoding=utf-8', \n" +
  119. "'table-name' = 'total_amount', \n" +
  120. "'username' = 'root', \n" +
  121. "'password' = '123456', \n" +
  122. "'connection.max-retry-timeout' = '60s', \n" +
  123. "'sink.max-retries' = '3', \n" +
  124. "'lookup.max-retries' = '3' \n" +
  125. ")";
  126. // 创建Sink表,连接到MySQL,累计实收额
  127. String sink_real_amount = "CREATE TABLE real_amount ( \n" +
  128. "id INT,\n" +
  129. "real_amount DECIMAL(16,2),\n" +
  130. "PRIMARY KEY (id) NOT ENFORCED \n" +
  131. ") WITH ( \n" +
  132. "'connector' = 'jdbc', \n" +
  133. "'url' = 'jdbc:mysql://bigdata:3306/report?useSSL=false&useUnicode=true&characterEncoding=utf-8', \n" +
  134. "'table-name' = 'real_amount', \n" +
  135. "'username' = 'root', \n" +
  136. "'password' = '123456', \n" +
  137. "'connection.max-retry-timeout' = '60s', \n" +
  138. "'sink.max-retries' = '3', \n" +
  139. "'lookup.max-retries' = '3' \n" +
  140. ")";
  141. // 创建Sink表,连接到MySQL,累计运营总人次
  142. String sink_people_cnt = "CREATE TABLE people_cnt ( \n" +
  143. "id INT,\n" +
  144. "people_cnt BIGINT,\n" +
  145. "PRIMARY KEY (id) NOT ENFORCED \n" +
  146. ") WITH ( \n" +
  147. "'connector' = 'jdbc', \n" +
  148. "'url' = 'jdbc:mysql://bigdata:3306/report?useSSL=false&useUnicode=true&characterEncoding=utf-8', \n" +
  149. "'table-name' = 'people_cnt', \n" +
  150. "'username' = 'root', \n" +
  151. "'password' = '123456', \n" +
  152. "'connection.max-retry-timeout' = '60s', \n" +
  153. "'sink.max-retries' = '3', \n" +
  154. "'lookup.max-retries' = '3' \n" +
  155. ")";
  156. // 每个站的累计营收额
  157. String station_amount = "insert into station_amount select station,sum(deal_money) from MetroSwipingData group by station";
  158. // 每个站点的累计出入站人数
  159. String station_peopleNum = "insert into station_peopleNum select \n" +
  160. "station,\n" +
  161. "sum(case when deal_type='地铁入站' then 1 else 0 end)as enterNum,\n" +
  162. "sum(case when deal_type='地铁出站' then 1 else 0 end)as outNum\n" +
  163. "from MetroSwipingData group by station";
  164. // 每条线路的营业额
  165. String line_amount = "insert into line_amount select company_name,sum(deal_value) as amount from MetroSwipingData group by company_name";
  166. // 每天客流量 sink
  167. // String data_peopleNum = "insert into data_peopleNum select close_date,count(DISTINCT card_no) as peopleNum from MetroSwipingData group by close_date";
  168. // 累计营收额 trans
  169. String total_amount = "insert into total_amount select 1 as id, sum(deal_value) as total_amount from MetroSwipingData";
  170. // 累计实收额
  171. String real_amount = "insert into real_amount select 1 as id, sum(deal_money) as real_amount from MetroSwipingData";
  172. // 累计总客运量
  173. String people_cnt = "insert into people_cnt select 1 as id, count(1) as people_cnt from MetroSwipingData where deal_type='地铁入站'";
  174. // 开始启动
  175. System.out.println("========================================== Flink任务开始启动... ==========================================");
  176. // 创建source表
  177. System.out.println("开始创建source表 [MetroSwipingData]...");
  178. tableEnv.executeSql(kafkaSource);
  179. System.out.println("source表 [MetroSwipingData] 创建成功...");
  180. // 创建sink表
  181. System.out.println("开始创建sink表 [station_amount]...");
  182. tableEnv.executeSql(sink_station_amount);
  183. tableEnv.executeSql(sink_station_peopleNum);
  184. tableEnv.executeSql(sink_line_amount);
  185. // tableEnv.executeSql(sink_data_peopleNum);
  186. tableEnv.executeSql(sink_total_amount);
  187. tableEnv.executeSql(sink_real_amount);
  188. tableEnv.executeSql(sink_people_cnt);
  189. System.out.println("sink表 [station_amount | station_peopleNum | station_peopleNum | line_amount | total_amount | real_amount | people_cnt] 创建成功...");
  190. // 开始执行计算逻辑
  191. System.out.println("开始执行逻辑操作");
  192. tableEnv.executeSql(station_amount);
  193. tableEnv.executeSql(station_peopleNum);
  194. tableEnv.executeSql(line_amount);
  195. // tableEnv.executeSql(data_peopleNum);
  196. tableEnv.executeSql(total_amount);
  197. tableEnv.executeSql(real_amount);
  198. tableEnv.executeSql(people_cnt);
  199. System.out.println("========================================== Flink任务启动成功... ==========================================");
  200. }
  201. }

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/酷酷是懒虫/article/detail/758552
推荐阅读
相关标签
  

闽ICP备14008679号