日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
太實(shí)用了!四種方法教你輕松制作交互式儀表板!

讓客戶深刻記住你的數(shù)據(jù)洞察和發(fā)現(xiàn)的最好方式,是創(chuàng)建交互式儀表板。為什么要互動(dòng)呢?一方面是比較有趣,另一方面是客戶對(duì)動(dòng)作的記憶比靜態(tài)的洞察力更深刻。

目前成都創(chuàng)新互聯(lián)已為數(shù)千家的企業(yè)提供了網(wǎng)站建設(shè)、域名、虛擬主機(jī)、網(wǎng)站托管、服務(wù)器租用、企業(yè)網(wǎng)站設(shè)計(jì)、梅河口網(wǎng)站維護(hù)等服務(wù),公司將堅(jiān)持客戶導(dǎo)向、應(yīng)用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長(zhǎng),共同發(fā)展。

在本文中,我給大家分享 4 款 Python 工具包,使用它們?yōu)閿?shù)據(jù)科學(xué)項(xiàng)目創(chuàng)建交互式儀表板非常的棒。喜歡本文記得收藏、關(guān)注、點(diǎn)贊。

1、Widgets

Ipywidgets(縮寫為 Widgets) 是一個(gè)代碼簡(jiǎn)單直觀的交互式包,它為 Jupyter Notebooks 中的 GUI 提供 HTML 架構(gòu)。

該包允許我們直接在 Jupyter Notebook 單元中創(chuàng)建交互式儀表板。

只需幾行代碼,你就可以將 Jupyter Notebook 改為儀表板。讓我用幾行代碼展示如何做到這一點(diǎn)。

首先,我們需要安裝所需的包。

pip install ipywidgets

然后,我們需要在 Jupyter Notebook 中啟用 Ipywidgets。要啟用它,請(qǐng)?jiān)诿钐崾痉袀鬟f以下代碼。

jupyter nbextension enable --py widgetsnbextension

我們可以在 Jupyter Notebook 中創(chuàng)建交互式儀表板,并配備所有必要的軟件包。我將使用泰坦尼克號(hào)樣本數(shù)據(jù)進(jìn)行舉例。

import seaborn as sns
titanic = sns.load_dataset('titanic')
titanic.head()

我想創(chuàng)建一個(gè)交互式儀表板,獲取按類別變量分組的泰坦尼克號(hào)票價(jià)平均值。在這種情況下,使用如下代碼:

#Creating the interactive dashboard
from ipywidgets import interact
@interact
def create_fare_plot(col = titanic.drop(['fare', 'age'], axis =1).columns):
sns.barplot(data = titanic, x = col, y ='fare')
plt.title(f'Mean Bar Plot of the Fare grouped by the {col}')

通過添加@interact代碼,我們啟動(dòng)了交互過程。

2、Voila

Voila-dashboards 是一個(gè)簡(jiǎn)單的 Python 包,它將一個(gè)簡(jiǎn)單的 Jupyter Notebook 變成一個(gè)漂亮的 Web 儀表板。

只需一行安裝代碼,我們就可以快速渲染 Jupyter Notebook。

讓我們安裝 Voila-dashboards。

pip install voila

完成 Voila 包的安裝后,刷新 Jupyter Notebook 并查看 notebook 選項(xiàng)卡。在那里你會(huì)發(fā)現(xiàn)一個(gè)新的 Voila 按鈕。

現(xiàn)在按下按鈕,即可自動(dòng)生成 Voila 儀表板。

3、Dash by Plotly

Dash by Plotly 是一個(gè)開源 Python 包,它是基于 Plotly 可視化的低代碼框架包。

要試用 Dash,先安裝軟件包。

pip install dash

安裝完成后,我將使用以下代碼創(chuàng)建一個(gè)簡(jiǎn)單的 Titanic 儀表板。

import dash
from dash import dcc, html
import plotly.express as px
import pandas as pd
import seaborn as sns
app = dash.Dash()
df = sns.load_dataset('titanic')
fig = px.scatter(
df,
x="fare",
y="age",
size="pclass",
color="alive",
hover_name="embark_town",
log_x=True,
size_max=60
)
app.layout = html.Div(children = [
html.H1(children='Titanic Dashboard'),
dcc.Graph(id="fare_vs_age", figure=fig)])
if __name__ == "__main__":
app.run_server(debug=True)

運(yùn)行上述代碼后,將在默認(rèn)(http://127.0.0.1:8050/)中啟動(dòng)儀表板。

我們可以添加一個(gè)回調(diào)交互來(lái)讓用戶輸入具有特定的輸出。

import dash
from dash import dcc, html, Input, Output
import plotly.express as px
import pandas as pd
import seaborn as sns
app = dash.Dash()
df = sns.load_dataset('titanic')
fig = px.scatter(
df,
x="fare",
y="age",
size="pclass",
color="alive",
hover_name="embark_town",
log_x=True,
size_max=60
)
app.layout = html.Div(children = [
html.H1(children='Titanic Dashboard'),
dcc.Graph(id="fare_vs_age", figure=fig),
#Add interactive callback here
html.H4("Change the value in the text box to see callbacks in action"),
html.Div([
"Input: ",
dcc.Input(id='my-input', value='initial value', type='text')
]),
html.Br(),
html.Div(id='my-output'),
])
@app.callback(
Output(component_id='my-output', component_property='children'),
Input(component_id='my-input', component_property='value')
)
def update_output_div(input_value):
return f'Output: {input_value}'
if __name__ == "__main__":
app.run_server(debug=True)

Dash by Plotly 在創(chuàng)建儀表板時(shí)非常方便,它提供了許多有用的 API。

4、Streamlit

Streamlit 是一個(gè)開源 Python 包,旨在為數(shù)據(jù)科學(xué)家和機(jī)器學(xué)習(xí)項(xiàng)目創(chuàng)建一個(gè) Web 應(yīng)用程序。

Streamlit 提供的 API 易于任何初學(xué)者使用,非常適合希望以交互方式構(gòu)建其數(shù)據(jù)組合的任何人。

讓我們先安裝 Streamlit 包。

pip install streamlit

安裝過程完成后,我們可以創(chuàng)建交互式儀表板。

讓我給你下面的代碼示例。

import streamlit as st
import pandas as pd
import plotly.express as px
import seaborn as sns
df = sns.load_dataset('titanic')
st.title('Titanic Dashboard')
st.subheader('Dataset')
st.dataframe(df)
st.subheader('Data Numerical Statistic')
st.dataframe(df.describe())
st.subheader('Data Visualization with respect to Survived')
left_column, right_column = st.columns(2)
with left_column:
'Numerical Plot'
num_feat = st.selectbox(
'Select Numerical Feature', df.select_dtypes('number').columns)
fig = px.histogram(df, x = num_feat, color = 'survived')
st.plotly_chart(fig, use_container_width=True)
with right_column:
'Categorical column'
cat_feat = st.selectbox(
'Select Categorical Feature', df.select_dtypes(exclude = 'number').columns)
fig = px.histogram(df, x =cat_feat, color = 'survived' )
st.plotly_chart(fig, use_container_width=True)

使用 VScode 將文件保存為 titanic_st.py,然后在終端中運(yùn)行該代碼。

streamlit run titanic_st.py

Streamlit 在上述地址上運(yùn)行,我們可以訪問我們的儀表板。

使用上面的簡(jiǎn)單代碼,我們創(chuàng)建了一個(gè)交互式儀表板,API 并不難理解,我們只使用最少數(shù)量的代碼。

結(jié)論

當(dāng)我們需要展示數(shù)據(jù)科學(xué)項(xiàng)目時(shí)建議用交互式儀表板,它將改善大大改善用戶體驗(yàn)。


網(wǎng)站題目:太實(shí)用了!四種方法教你輕松制作交互式儀表板!
網(wǎng)頁(yè)網(wǎng)址:http://www.dlmjj.cn/article/cdjjips.html