[畢業(yè)設(shè)計]2023-2024年最新最全計算機(jī)專業(yè)畢設(shè)選題推薦匯總
感興趣的可以先收藏起來,還有大家在畢設(shè)選題,項目以及論文編寫等相關(guān)問題都可以給我留言咨詢,希望幫助更多的人?。
1、摘 要
隨著氣候變化的不斷加劇,氣象數(shù)據(jù)的準(zhǔn)確性和時效性變得愈發(fā)重要。本論文介紹了一個基于Python網(wǎng)絡(luò)爬蟲技術(shù)的天氣數(shù)據(jù)自動獲取與可視化分析系統(tǒng),該系統(tǒng)可以自動地從中國天氣網(wǎng)獲取實(shí)時天氣數(shù)據(jù),并將數(shù)據(jù)清洗、存儲在MYSQL數(shù)據(jù)庫中。同時,通過ECharts技術(shù)實(shí)現(xiàn)數(shù)據(jù)可視化,在大屏幕上實(shí)現(xiàn)了全國綜合天氣數(shù)據(jù)可視化,以及全國各城市和上海歷史天氣數(shù)據(jù)的可視化。其次,系統(tǒng)還實(shí)現(xiàn)了機(jī)器學(xué)習(xí)預(yù)測天氣模型構(gòu)建與訓(xùn)練,使用scikit-learn、pandas、numpy等工具實(shí)現(xiàn)多元線性回歸模型。預(yù)測模型可以對天氣趨勢進(jìn)行分析,提供預(yù)測結(jié)果。此外,該系統(tǒng)還實(shí)現(xiàn)了用戶登錄和注冊功能,以及數(shù)據(jù)管理模塊,用于管理用戶數(shù)據(jù)、公告數(shù)據(jù)、全國天氣數(shù)據(jù)和上海歷史氣象數(shù)據(jù)。
總的來說,本系統(tǒng)實(shí)現(xiàn)了數(shù)據(jù)的自動獲取和處理,提供了可視化的天氣數(shù)據(jù)分析和預(yù)測模型,并具有用戶管理和數(shù)據(jù)管理功能。這個系統(tǒng)不僅具有很高的實(shí)用價值,同時也為未來的氣象數(shù)據(jù)研究提供了一個有價值的數(shù)據(jù)源。
關(guān)鍵字:可視化;Python;網(wǎng)絡(luò)爬蟲;天氣
2、項目框架
系統(tǒng)功能主要包括數(shù)據(jù)采集功能、數(shù)據(jù)可視化功能、數(shù)據(jù)預(yù)測功能、用戶登錄與注冊功能、數(shù)據(jù)管理功能。其中數(shù)據(jù)采集功能包含全國實(shí)時天氣數(shù)據(jù)采集和上海歷史天氣數(shù)據(jù)采集。數(shù)據(jù)可視化功能包含全國綜合天氣數(shù)據(jù)可視化、全國各城市天氣數(shù)據(jù)可視化以及上海歷史天氣數(shù)據(jù)可視化。數(shù)據(jù)預(yù)測功能指的是氣象分析預(yù)測;數(shù)據(jù)管理指的是多維度的數(shù)據(jù)管理,包含用戶數(shù)據(jù)、公告數(shù)據(jù)、全國氣象數(shù)據(jù)管理等。
數(shù)據(jù)預(yù)測模塊功能實(shí)現(xiàn)
氣象數(shù)據(jù)分析預(yù)測模塊包括氣象數(shù)據(jù)預(yù)測模型的訓(xùn)練以及利用現(xiàn)有氣象數(shù)據(jù),加載氣象模型進(jìn)行預(yù)測。
首先氣象數(shù)據(jù)預(yù)測是根據(jù)各地區(qū)近12個月的上海的歷史氣象數(shù)據(jù)做為數(shù)據(jù)級,首先從數(shù)據(jù)庫中導(dǎo)出CSV格式的數(shù)據(jù),然后利用pandas和numpy技術(shù)對數(shù)據(jù)進(jìn)行預(yù)處理、格式化數(shù)據(jù)以及數(shù)據(jù)集分割。分割完成后,試用sklearn庫進(jìn)行構(gòu)建多元線性回歸模型,再將分割后的數(shù)據(jù)進(jìn)行投喂,訓(xùn)練模型。最終將模型保存并計算模型的EMS損失值用于參考模型的訓(xùn)練效果。
3、項目運(yùn)行截圖
(1)城市數(shù)據(jù)分析
(2)氣象分析----數(shù)據(jù)概況
(3)氣象分析2
(4)算法預(yù)測
(5)氣象數(shù)據(jù)
(6)用戶管理
(7)注冊登錄
(8)數(shù)據(jù)采集
3、部分代碼
import datetime
from flask import Flask as _Flask, flash, redirect
from flask import request, session
from flask import render_template
from flask.json import JSONEncoder as _JSONEncoder, jsonify
import decimal
import os
from flask_apscheduler import APScheduler
from service import user_service, current_weather_service, detail_weather_service, history_weather_service, \
spider_service, city_service, notice_service, slog_service, data_service, predict_service
from utils.JsonUtils import read_json
import datetime
from utils.Result import Result
base = os.path.dirname(__file__)
directory_path = os.path.dirname(__file__)
json_path = directory_path + '/static/api/'
class JSONEncoder(_JSONEncoder):
def default(self, o):
if isinstance(o, decimal.Decimal):
return float(o)
if isinstance(o, datetime.datetime):
return o.strftime("%Y-%m-%d %H:%M:%S")
if isinstance(o, datetime.date):
return o.strftime("%Y-%m-%d")
super(_JSONEncoder, self).default(o)
class Flask(_Flask):
json_encoder = JSONEncoder
import os
app = Flask(__name__)
app.config['SESSION_TYPE'] = 'filesystem'
app.config['SECRET_KEY'] = os.urandom(24)
app.config['PERMANENT_SESSION_LIFETIME'] = datetime.timedelta(days=1)
# ----------------------------------------------頁面加載模塊開始----------------------------------------------
# 加載系統(tǒng)json文件
@app.route('/api/<string:path>/')
def api_json(path):
if path == 'init.json' and session.get('user') and session.get('user')['type'] == 1:
path = 'custom_init.json'
return read_json(json_path + path)
# 加載page下的靜態(tài)頁面
@app.route('/page/<string:path>')
def api_path(path):
return render_template("page/" + path)
# 系統(tǒng)默認(rèn)路徑后臺跳轉(zhuǎn)
@app.route('/admin')
def admin_page():
if session.get('user') and session.get('user')['id'] > 0:
return render_template("index.html")
else:
return redirect("/login")
# 系統(tǒng)默認(rèn)路徑前臺跳轉(zhuǎn)
@app.route('/')
def main_page():
return render_template("page/login.html")
# 系統(tǒng)登錄路徑
@app.route('/login')
def login_page():
return render_template("page/login.html")
# 系統(tǒng)退出登錄路徑
@app.route('/logout')
def logout_page():
session.clear()
return redirect("/login")
# 系統(tǒng)注冊用戶
@app.route('/register', methods=['get'])
def register_page():
return render_template("page/register.html")
# ----------------------------------------------頁面加載模塊結(jié)束----------------------------------------------
# ----------------------------------------------用戶相關(guān)模塊開始----------------------------------------------
# 用戶注冊
@app.route('/register', methods=['post'])
def register_user():
form = request.form.to_dict() # 獲取值
result = user_service.insert_user(form)
return result.get()
# 用戶登錄
@app.route('/login', methods=['post'])
def login_user():
form = request.form.to_dict() # 獲取值
result = user_service.select_user_by_account_password(form)
session['user'] = result.data
return result.get()
# ----------------------------------------------用戶相關(guān)模塊結(jié)束----------------------------------------------
# ----------------------------------------------全國氣象相關(guān)模塊開始----------------------------------------------
# 全國氣象數(shù)據(jù)分頁
@app.route('/page/current/weather/add', methods=['get'])
def page_current_weather_add():
city_list = current_weather_service.get_city_list()
wd_list = current_weather_service.get_wd_list()
weather_list = current_weather_service.get_weather_list()
return render_template("page/currentWeather/add.html", city_list=city_list, weather_list=weather_list,
wd_list=wd_list)
# 添加全國氣象數(shù)據(jù)
@app.route('/add/current/weather', methods=['post'])
def add_current_weather():
form = request.form.to_dict()
result = current_weather_service.insert_current_weather(form)
return result.get()
# 全國氣象數(shù)據(jù)編輯頁面
@app.route('/page/current/weather/edit', methods=['get'])
def page_current_weather_edit():
id = request.args.get('id')
current_weather = current_weather_service.get_current_weather(id)
city_list = current_weather_service.get_city_list()
wd_list = current_weather_service.get_wd_list()
weather_list = current_weather_service.get_weather_list()
return render_template("page/currentWeather/edit.html", city_list=city_list, weather_list=weather_list,
wd_list=wd_list, current_weather=current_weather)
# 編輯全國氣象接口
@app.route('/edit/current/weather', methods=['post'])
def edit_current_weather():
form = request.form.to_dict()
result = current_weather_service.edit_current_weather(form)
return result.get()
# 單個刪除全國氣象接口
@app.route('/del/current/weather/<int:id>', methods=['post'])
def del_current_weather(id):
result = current_weather_service.del_current_weather(id)
return result.get()
# 批量刪除全國氣象接口
@app.route('/del/current/weather', methods=['post'])
def del_current_weather_list():
ids = request.args.get('ids')
result = current_weather_service.del_current_weather_list(ids)
return result.get()
# 全國氣象數(shù)據(jù)分頁
@app.route('/list/current/weather', methods=['get'])
def current_weather_list():
page = request.args.get('page')
limit = request.args.get('limit')
where = request.args.get('searchParams')
result = current_weather_service.select_current_weather_list(page, limit, where)
return result.get()
# ----------------------------------------------全國氣象相關(guān)模塊結(jié)束----------------------------------------------
# ----------------------------------------------上海氣象相關(guān)模塊開始----------------------------------------------
# 上海氣象數(shù)據(jù)分頁
@app.route('/page/detail/weather/add', methods=['get'])
def page_detail_weather_add():
city_list = detail_weather_service.get_city_list()
wd_list = detail_weather_service.get_wd_list()
weather_list = detail_weather_service.get_weather_list()
return render_template("page/detailWeather/add.html", city_list=city_list, weather_list=weather_list,
wd_list=wd_list)
# 添加上海氣象數(shù)據(jù)
@app.route('/add/detail/weather', methods=['post'])
def add_detail_weather():
form = request.form.to_dict()
result = detail_weather_service.insert_detail_weather(form)
return result.get()
# 上海氣象數(shù)據(jù)編輯頁面
@app.route('/page/detail/weather/edit', methods=['get'])
def page_detail_weather_edit():
id = request.args.get('id')
detail_weather = detail_weather_service.get_detail_weather(id)
city_list = detail_weather_service.get_city_list()
wd_list = detail_weather_service.get_wd_list()
weather_list = detail_weather_service.get_weather_list()
return render_template("page/detailWeather/edit.html", city_list=city_list, weather_list=weather_list,
wd_list=wd_list, detail_weather=detail_weather)
# 編輯上海氣象接口
@app.route('/edit/detail/weather', methods=['post'])
def edit_detail_weather():
form = request.form.to_dict()
result = detail_weather_service.edit_detail_weather(form)
return result.get()
# 單個刪除上海氣象接口
@app.route('/del/detail/weather/<int:id>', methods=['post'])
def del_detail_weather(id):
result = detail_weather_service.del_detail_weather(id)
return result.get()
# 批量刪除上海氣象接口
@app.route('/del/detail/weather', methods=['post'])
def del_detail_weather_list():
ids = request.args.get('ids')
result = detail_weather_service.del_detail_weather_list(ids)
return result.get()
# 上海氣象數(shù)據(jù)分頁
@app.route('/list/detail/weather', methods=['get'])
def detail_weather_list():
page = request.args.get('page')
limit = request.args.get('limit')
where = request.args.get('searchParams')
result = detail_weather_service.select_detail_weather_list(page, limit, where)
return result.get()
# ----------------------------------------------上海氣象相關(guān)模塊結(jié)束----------------------------------------------
# ----------------------------------------------上海歷史氣象相關(guān)模塊開始----------------------------------------------
# 上海歷史數(shù)據(jù)分頁
@app.route('/page/history/weather/add', methods=['get'])
def page_history_weather_add():
city_list = history_weather_service.get_city_list()
wd_list = history_weather_service.get_wd_list()
weather_list = history_weather_service.get_weather_list()
return render_template("page/historyWeather/add.html", city_list=city_list, weather_list=weather_list,
wd_list=wd_list)
# 添加上海歷史數(shù)據(jù)
@app.route('/add/history/weather', methods=['post'])
def add_history_weather():
form = request.form.to_dict()
result = history_weather_service.insert_history_weather(form)
return result.get()
# 上海歷史編輯頁面
@app.route('/page/history/weather/edit', methods=['get'])
def page_history_weather_edit():
id = request.args.get('id')
history_weather = history_weather_service.get_history_weather(id)
city_list = history_weather_service.get_city_list()
wd_list = history_weather_service.get_wd_list()
weather_list = history_weather_service.get_weather_list()
return render_template("page/historyWeather/edit.html", city_list=city_list, weather_list=weather_list,
wd_list=wd_list, history_weather=history_weather)
# 編輯上海歷史接口
@app.route('/edit/history/weather', methods=['post'])
def edit_history_weather():
form = request.form.to_dict()
result = history_weather_service.edit_history_weather(form)
return result.get()
# 單個刪除上海歷史接口
@app.route('/del/history/weather/<int:id>', methods=['post'])
def del_history_weather(id):
result = history_weather_service.del_history_weather(id)
return result.get()
# 批量刪除上海歷史接口
@app.route('/del/history/weather', methods=['post'])
def del_history_weather_list():
ids = request.args.get('ids')
result = history_weather_service.del_history_weather_list(ids)
return result.get()
# 上海歷史氣象數(shù)據(jù)分頁
@app.route('/list/history/weather', methods=['get'])
def history_weather_list():
page = request.args.get('page')
limit = request.args.get('limit')
where = request.args.get('searchParams')
result = history_weather_service.select_history_weather_list(page, limit, where)
return result.get()
# ----------------------------------------------上海歷史氣象相關(guān)模塊結(jié)束----------------------------------------------
# ----------------------------------------------用戶相關(guān)模塊開始----------------------------------------------
# 用戶數(shù)據(jù)分頁
@app.route('/page/user/add', methods=['get'])
def page_user_add():
return render_template("page/user/add.html")
@app.route('/add/user', methods=['post'])
def add_user():
form = request.form.to_dict()
result = user_service.insert_user(form)
return result.get()
# 用戶修改密碼
@app.route('/user/reset/password', methods=['post'])
def reset_password_user():
form = request.form.to_dict() # 獲取值
result = user_service.reset_password(form['old_password'], form['new_password'], form['again_password'])
return result.get()
# 用戶編輯頁面
@app.route('/page/user/edit', methods=['get'])
def page_user_edit():
id = request.args.get('id')
user = user_service.get_user(id)
return render_template("page/user/edit.html", user=user)
# 編輯用戶接口
@app.route('/edit/user', methods=['post'])
def edit_user():
form = request.form.to_dict()
result = user_service.edit_user(form)
return result.get()
# 單個刪除用戶接口
@app.route('/del/user/<int:id>', methods=['post'])
def del_user(id):
result = user_service.del_user(id)
return result.get()
# 批量刪除用戶接口
@app.route('/del/user', methods=['post'])
def del_user_list():
ids = request.args.get('ids')
result = user_service.del_user_list(ids)
return result.get()
# 用戶數(shù)據(jù)分頁
@app.route('/list/user', methods=['get'])
def user_list():
page = request.args.get('page')
limit = request.args.get('limit')
where = request.args.get('searchParams')
result = user_service.select_user_list(page, limit, where)
return result.get()
# ----------------------------------------------用戶相關(guān)模塊結(jié)束----------------------------------------------
# ----------------------------------------------公告相關(guān)模塊開始----------------------------------------------
# 公告添加頁面
@app.route('/page/notice/add', methods=['get'])
def page_notice_add():
return render_template("page/notice/add.html")
@app.route('/add/notice', methods=['post'])
def add_notice():
form = request.form.to_dict()
result = notice_service.insert_notice(form)
return result.get()
# 數(shù)據(jù)公告編輯頁面
@app.route('/page/notice/edit', methods=['get'])
def page_notice_edit():
id = request.args.get('id')
notice = notice_service.get_notice(id)
return render_template("page/notice/edit.html", notice=notice)
# 編輯公告接口
@app.route('/edit/notice', methods=['post'])
def edit_notice():
form = request.form.to_dict()
result = notice_service.edit_notice(form)
return result.get()
# 單個刪除公告接口
@app.route('/del/notice/<int:id>', methods=['post'])
def del_notice(id):
result = notice_service.del_notice(id)
return result.get()
# 批量刪除公告接口
@app.route('/del/notice', methods=['post'])
def del_notice_list():
ids = request.args.get('ids')
result = notice_service.del_notice_list(ids)
return result.get()
# 公告數(shù)據(jù)分頁
@app.route('/list/notice', methods=['get'])
def notice_list():
page = request.args.get('page')
limit = request.args.get('limit')
where = request.args.get('searchParams')
result = notice_service.select_notice_list(page, limit, where)
return result.get()
# 公告數(shù)據(jù)分頁
@app.route('/get/notice/new', methods=['get'])
def get_new_notice():
result = notice_service.get_notice_by_new()
return result.get()
# ----------------------------------------------公告相關(guān)模塊結(jié)束----------------------------------------------
# ----------------------------------------------日志相關(guān)模塊開始----------------------------------------------
# 單個刪除日志接口
@app.route('/del/slog/<int:id>', methods=['post'])
def del_slog(id):
result = slog_service.del_slog(id)
return result.get()
# 批量刪除日志接口
@app.route('/del/slog', methods=['post'])
def del_slog_list():
ids = request.args.get('ids')
result = slog_service.del_slog_list(ids)
return result.get()
# 日志數(shù)據(jù)分頁
@app.route('/list/slog', methods=['get'])
def slog_list():
page = request.args.get('page')
limit = request.args.get('limit')
where = request.args.get('searchParams')
result = slog_service.select_slog_list(page, limit, where)
return result.get()
# ----------------------------------------------日志相關(guān)模塊結(jié)束----------------------------------------------
# ----------------------------------------------分析相關(guān)模塊開始----------------------------------------------
# 上海城市數(shù)據(jù)分析
@app.route('/data/history/weather', methods=['post', 'get'])
def data_history_category():
city = request.args.get('city')
result_weather = data_service.weather_category_data(city)
result_wd = data_service.wd_category_data(city)
result_ws = data_service.ws_category_data(city)
result_temp = data_service.temp_data(city)
return {"weather_data": result_weather, "wd_data": result_wd, "ws_data": result_ws, "temp_data": result_temp}
# 城市實(shí)時數(shù)據(jù)分析
@app.route('/data/china/weather', methods=['post', 'get'])
def data_china_category():
city = request.args.get('city')
model = current_weather_service.select_current_weather_by_city(city)
result_data = data_service.current_change_data(city)
return {"model": model, "result_data": result_data}
# 城市實(shí)時數(shù)據(jù)分析
@app.route('/data/home/weather', methods=['post', 'get'])
def data_home_category():
return data_service.top_page_data()
# 城市實(shí)時數(shù)據(jù)分析
@app.route('/data/weather/predict', methods=['post', 'get'])
def data_predict():
city = request.args.get('city')
return predict_service.predict(city)
# ----------------------------------------------分析相關(guān)模塊結(jié)束----------------------------------------------
# ----------------------------------------------爬蟲相關(guān)模塊開始----------------------------------------------
from concurrent.futures import ThreadPoolExecutor
# 爬蟲自動運(yùn)行
def job_function():
print("爬蟲任務(wù)執(zhí)行開始!")
executor = ThreadPoolExecutor(2)
executor.submit(spider_service.main_spider())
def task():
scheduler = APScheduler()
scheduler.init_app(app)
# 定時任務(wù),每隔600s執(zhí)行1次
scheduler.add_job(func=job_function, trigger='interval', seconds=600, id='my_cloud_spider_id')
scheduler.start()
# 后臺調(diào)用爬蟲
@app.route('/spider/start', methods=["POST"])
def run_spider():
executor = ThreadPoolExecutor(2)
executor.submit(spider_service.main_spider())
return '200'
# 寫在main里面,IIS不會運(yùn)行
task()
# run_spider()#啟動項目就運(yùn)行一次爬蟲
# ----------------------------------------------爬蟲相關(guān)模塊結(jié)束----------------------------------------------
if __name__ == '__main__':
# 端口號設(shè)置
app.run(host="127.0.0.1", port=5000)
4、總結(jié)
天氣數(shù)據(jù)自動獲取與可視化分析系統(tǒng)是一個功能完備、性能穩(wěn)定、安全可靠且具有良好兼容性的系統(tǒng)。通過該系統(tǒng),用戶能夠?qū)崟r獲取國內(nèi)各地區(qū)的天氣數(shù)據(jù),并進(jìn)行數(shù)據(jù)分析和可視化展示,從而為用戶的決策和實(shí)踐活動提供有力支持。在系統(tǒng)的設(shè)計和開發(fā)過程中,我們遵循了模塊化設(shè)計、分層設(shè)計、內(nèi)聚低耦合、可靠性和統(tǒng)一性等設(shè)計原則,以確保系統(tǒng)的可重用性、可維護(hù)性和易擴(kuò)展性。
系統(tǒng)經(jīng)過多次測試,得出了積極的測試結(jié)果。系統(tǒng)展現(xiàn)了穩(wěn)定的性能,在正常負(fù)載下能夠快速響應(yīng)用戶請求并處理大量數(shù)據(jù)。同時,系統(tǒng)保障了用戶數(shù)據(jù)的安全和隱私,并且在不同瀏覽器和操作系統(tǒng)上都能夠正常運(yùn)行。
從經(jīng)濟(jì)可行性分析角度看,該系統(tǒng)能夠提高天氣數(shù)據(jù)的獲取效率和分析準(zhǔn)確性,幫助用戶做出更好的決策,具有一定的商業(yè)價值和市場前景。
源碼獲?。?/h4>
????文章來源:http://www.zghlxwxcb.cn/news/detail-778795.html
大家點(diǎn)贊、收藏、關(guān)注、評論啦 、查看用戶名獲取項目源碼????文章來源地址http://www.zghlxwxcb.cn/news/detail-778795.html
????文章來源:http://www.zghlxwxcb.cn/news/detail-778795.html
大家點(diǎn)贊、收藏、關(guān)注、評論啦 、查看用戶名獲取項目源碼????文章來源地址http://www.zghlxwxcb.cn/news/detail-778795.html
到了這里,關(guān)于計算機(jī)畢業(yè)設(shè)計:基于python機(jī)器學(xué)習(xí)的全國氣象數(shù)據(jù)采集預(yù)測可視化系統(tǒng) 預(yù)測模型+爬蟲(包含文檔+源碼+部署教程)的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!