0 簡介
今天學(xué)長向大家分享一個畢業(yè)設(shè)計項目
畢業(yè)設(shè)計 基于大數(shù)據(jù)的游數(shù)據(jù)分析可視化系統(tǒng)(源碼分享)
演示效果
畢業(yè)設(shè)計 大同旅游數(shù)據(jù)分析可視化系統(tǒng)
項目獲?。?/strong>文章來源:http://www.zghlxwxcb.cn/news/detail-766624.html
https://gitee.com/sinonfin/algorithm-sharing文章來源地址http://www.zghlxwxcb.cn/news/detail-766624.html
1 課題背景
精神文明日益發(fā)展的今天, 出行旅游成為人們的主要休閑方式和社會經(jīng)濟(jì)活動, 旅游業(yè)不僅能推動多個產(chǎn)業(yè)的發(fā)展, 調(diào)節(jié)產(chǎn)業(yè)結(jié)構(gòu), 同時也滿足了人們?nèi)找嬖鲩L的文化需要。其越來越成為國民經(jīng)濟(jì)的重要支撐。相關(guān)數(shù)據(jù)顯示, 疫情平穩(wěn)期間的旅游人數(shù)仍然穩(wěn)中有增。而與之相對應(yīng)的是海量的無序化旅游數(shù)據(jù)日益激增。針對有效旅游數(shù)據(jù)進(jìn)行準(zhǔn)確分析、 合理預(yù)測有助于制定與旅游發(fā)展相關(guān)的規(guī)劃, 同時能有效地幫助后續(xù)在旅游設(shè)施分配和資源調(diào)度等方面上制定明智的決策, 發(fā)揮旅游信息價值的最大化。由此可知, 旅游經(jīng)濟(jì)的發(fā)展與對數(shù)據(jù)的合理分析是密不可分的。
2 數(shù)據(jù)處理
采用Python爬蟲技術(shù)對某大同市旅游景點(diǎn)數(shù)據(jù)進(jìn)行采集,用Python中的Pandas庫對采集到的數(shù)據(jù)進(jìn)行整理, 首先將旅游數(shù)據(jù)轉(zhuǎn)化成DataFrame格式, 再從多個維度和角度進(jìn)行處理分析。使用isnull函數(shù)選取查看缺失值占總數(shù)據(jù)百分比大于90%的列名及其數(shù)值, 認(rèn)為它在數(shù)據(jù)分析中提供極其有限信息, 所以直接刪除。對缺失數(shù)據(jù)采用fillna函數(shù)根據(jù)數(shù)據(jù)的不同類型進(jìn)行了固定值填充, 異常值(也稱為離群值)檢測是一個重要的部分, 用duplicated函數(shù)表示重復(fù)行的布爾系列值, 返回缺失總數(shù)后進(jìn)行去重。
采用選擇(loc)、 分組(groupby)、 連接(merge)、 匯總統(tǒng)計(mean)等方法進(jìn)行數(shù)據(jù)的統(tǒng)計與處理。處理完后利用其自帶接口將數(shù)據(jù)存入到mysql數(shù)據(jù)庫中。
3 數(shù)據(jù)可視化工具
3.1 django框架介紹
數(shù)據(jù)可視化是數(shù)據(jù)處理中的重要部分
Django是一個基于Web的應(yīng)用框架,由python編寫。Web開發(fā)的基礎(chǔ)是B/S架構(gòu),它通過前后端配合,將后臺服務(wù)器的數(shù)據(jù)在瀏覽器上展現(xiàn)給前臺用戶的應(yīng)用。Django本身是基于MVC模型,即Model(模型)+View(視圖)+ Controller(控制器)設(shè)計模式,View模塊和Template模塊組成了它的視圖部分,這種結(jié)構(gòu)使動態(tài)的邏輯是剝離于靜態(tài)頁面處理的。 Django框架的Model層本質(zhì)上是一套ORM系統(tǒng),封裝了大量的數(shù)據(jù)庫操作API,開發(fā)人員不需要知道底層的數(shù)據(jù)庫實(shí)現(xiàn)就可以對數(shù)據(jù)庫進(jìn)行增刪改查等操作。Django強(qiáng)大的QuerySet設(shè)計能夠?qū)崿F(xiàn)非常復(fù)雜的數(shù)據(jù)庫查詢操作,且性能接近原生SQL語句。Django支持包括PostgreSQL、My Sql、SQLite、Oracle在內(nèi)的多種數(shù)據(jù)庫。Django的路由層設(shè)計非常簡潔,使得將控制層、模型層和頁面模板獨(dú)立開進(jìn)行開發(fā)成為可能?;贒jango的Web系統(tǒng)工程結(jié)構(gòu)示意圖如圖所示。
從圖中可以看到,一個完整的Django工程由數(shù)個分應(yīng)用程序組成,每個分應(yīng)用程序包括四個部分:
(1)urls路由層:決定Web系統(tǒng)路由結(jié)構(gòu),控制頁面間的跳轉(zhuǎn)和數(shù)據(jù)請求路徑
(2)views視圖層:業(yè)務(wù)層,主要進(jìn)行邏輯操作和運(yùn)算,是前端頁面模板和后端數(shù)據(jù)庫之間的橋梁。Django框架提供了大量的數(shù)據(jù)庫操作API,開發(fā)人員甚至不需要使用SQL語句即可完成大部分的數(shù)據(jù)庫操作。
(3)models模型層:Web應(yīng)用連接底層數(shù)據(jù)庫的關(guān)鍵部分,封裝了數(shù)據(jù)庫表結(jié)構(gòu)和實(shí)現(xiàn)。開發(fā)人員可以在Model層按照Django的指令要求進(jìn)行建表,無須使用SQL語句或者第三方建表工具進(jìn)行建表。建表的過程類似于定義變量和抽象編程語言中的類,非常方便。
(4)templates模板層:HTML模板文件,后端數(shù)據(jù)會填充HTML模板,渲染之后返回給前端請求??紤]到項目周期盡可能小,盡快完成平臺的搭建,項目決定采用開源的Django框架開發(fā)整個系統(tǒng)的Web應(yīng)用層。
3.2 ECharts
ECharts(Enterprise Charts)是百度開源的數(shù)據(jù)可視化工具,底層依賴輕量級Canvas庫ZRender。兼容了幾乎全部常用瀏覽器的特點(diǎn),使它可廣泛用于PC客戶端和手機(jī)客戶端。ECharts能輔助開發(fā)者整合用戶數(shù)據(jù),創(chuàng)新性的完成個性化設(shè)置可視化圖表。支持折線圖(區(qū)域圖)、柱狀圖(條狀圖)、散點(diǎn)圖(氣泡圖)、K線圖、餅圖(環(huán)形圖)等,通過導(dǎo)入 js 庫在 Java Web 項目上運(yùn)行。
4 Django使用echarts進(jìn)行可視化展示(mysql數(shù)據(jù)庫)
4.1 修改setting.py連接mysql數(shù)據(jù)庫
# settings.py 文件
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
# mysql 數(shù)據(jù)庫名
'NAME': 'my_db',
# mysql 登陸用戶名
'USER': 'root',
# myslq 登陸密碼
'PASSWORD': '123456',
'HOST': 'localhost',
'PORT': '3306',
}
}
4.2 導(dǎo)入數(shù)據(jù)
可以直接在 mysql 數(shù)據(jù)庫中添加數(shù)據(jù),也可以使用超級用戶在 admin 管理頁面中添加數(shù)據(jù)
from django.db import models
# Create your models here.
# 然后輸入
# python manage.py makemigrations #數(shù)據(jù)庫變動的記錄(并不會幫你創(chuàng)建表)
# python manage.py migrate #將你的數(shù)據(jù)庫變動同步到數(shù)據(jù)庫中(這下才是真正創(chuàng)建表了)
class Cityall(models.Model):
id = models.AutoField(primary_key=True)
cityname = models.CharField(max_length=100, blank=True)
renqi = models.CharField(max_length=100, blank=True)
hot = models.CharField(max_length=100, blank=True)
class Meta:
db_table = 'cityall'
數(shù)據(jù)庫內(nèi)容:
4.3 使用echarts可視化展示
- 設(shè)置靜態(tài)文件目錄(即 static 目錄)
# settings.py 文件
STATICFILES_DIRS=(os.path.join(BASE_DIR,'static'),)
- 創(chuàng)建如下目錄結(jié)構(gòu):
- js 目錄中為 echarts的 js 文件,大家可以在 echarts官網(wǎng)下載自己需要的版本,index.html 文件內(nèi)容如下
#部分代碼,不完整
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>大同市旅游景點(diǎn)可視化系統(tǒng)</title>
<script src="/static/jquery/jquery-1.8.3.min.js"></script>
<script src="https://libs.baidu.com/jquery/1.10.2/jquery.min.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/echarts/4.2.1/echarts.min.js"></script>
</head>
<body>
<div class="container-header">
<ul class="nowTime">
<li></li>
<li></li>
</ul>
<div class="location">
<i class="icon iconfont icon-buoumaotubiao23"></i>
<span class="areaName"></span>
</div>
<h3 style="font-size:28px;"> 大同市旅游景點(diǎn)可視化系統(tǒng)
</h3>
</div>
<div class="container-content">
<div class="top">
<div class="count-base">
<div class="com-count-title">A級景區(qū)比例</div>
<div class="com-screen-content">
<div id="main1" style="width:100%;height:300px;"></div>
</div>
<span class="left-top"></span>
<span class="right-top"></span>
<span class="left-bottom"></span>
<span class="right-bottom"></span>
</div>
<div class="count-resource q1">
<div class="com-count-title">旅游資源統(tǒng)計</div>
<div class="com-screen-content2">
<ul class="use-data">
<li>
<p class="data-count" id="jinqunum">0 </p>
<span class="data-name">A級景區(qū)</span>
</li>
<li>
<p class="data-count" id="jiudiannum"> 0</p>
<span class="data-name">星級酒店</span>
</li>
<li>
<p class="data-count" id="lvxingshe">0</p>
<span class="data-name">旅行社</span>
</li>
</ul>
<div class="com-screen-content">
<div id="main2" style="margin-top:10px;width:100%;height:240px;"></div>
</div>
<span class="left-top"></span>
<span class="right-top"></span>
<span class="left-bottom"></span>
<span class="right-bottom"></span>
</div>
</div>
<div class="count-resource q2">
<div class="com-count-title">游記數(shù)據(jù)</div>
<div class="com-screen-content">
<ul class="data-label">
<li class="active" data-type="1">游記</li>
</ul>
<ul class="use-data">
</ul>
<div id="main3" style="margin-top:10px;width:100%;height:240px;">
</div>
</div>
<span class="left-top"></span>
<span class="right-top"></span>
<span class="left-bottom"></span>
<span class="right-bottom"></span>
</div>
</div>
......
-
編寫 views.py 文件,將數(shù)據(jù)庫中的數(shù)據(jù)傳到前端頁面中
import json from multiprocessing import connection from sqlite3.dbapi2 import IntegrityError from django.core import serializers from django.core.serializers.json import DjangoJSONEncoder from django.forms import model_to_dict from django.http import HttpResponse, JsonResponse from django.shortcuts import render def index(request): # print(request.method) #獲取請求方式GET或POST return render(request, 'index.html') # 回復(fù)一個頁面
5 實(shí)現(xiàn)效果
使用的數(shù)據(jù)是處理好后導(dǎo)入到mysql數(shù)據(jù)庫中的數(shù)據(jù),現(xiàn)在,我們來看一下展示效果,運(yùn)行
python manage.py runserver
5.1前端展示
設(shè)計 大同旅游數(shù)據(jù)分析可視化系統(tǒng)
最后
項目獲?。?/strong>
https://gitee.com/sinonfin/algorithm-sharing
到了這里,關(guān)于畢業(yè)設(shè)計 基于大數(shù)據(jù)的游數(shù)據(jù)分析可視化系統(tǒng)(源碼分享)的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!