日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

新冠肺炎的可视化和预测分析(附代码)

發(fā)布時(shí)間:2025/3/8 编程问答 20 豆豆
生活随笔 收集整理的這篇文章主要介紹了 新冠肺炎的可视化和预测分析(附代码) 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

新冠肺炎現(xiàn)在情況怎么樣了?推薦一份Jupyter notebook代碼進(jìn)行了分析,把數(shù)據(jù)可視化,并對感染人數(shù)進(jìn)行了預(yù)測。

來源:https://www.kaggle.com/corochann/covid-19-eda-with-recent-update-on-april?scriptVersionId=32149572

本文的可視化通過ployly實(shí)現(xiàn)。

本文數(shù)據(jù)更新到4月14日,最新數(shù)據(jù)下載:

https://www.kaggle.com/corochann/covid-19-eda-with-recent-update-on-april/data?scriptVersionId=32149572

(下載train.csv、test.csv、usa_states2.csv)?到input的convid19目錄即可,數(shù)據(jù)更新到2020-4-14。

原始數(shù)據(jù)是這里下載修改的:

https://github.com/CSSEGISandData/COVID-19

完整代碼放在github下載:

https://github.com/fengdu78/machine_learning_beginner/tree/master/covid19

代碼內(nèi)容

這份分析代碼主要分為以下幾個(gè)部分:

  • 全球趨勢

  • 國家(地區(qū))增長

  • 省份情況

  • 放大美國:現(xiàn)在美國正在發(fā)生什么?

  • 歐洲

  • 亞洲

  • 現(xiàn)在哪個(gè)國家正在復(fù)蘇?

  • 什么時(shí)候會收斂?通過S型擬合進(jìn)行預(yù)測

全球趨勢

fig = px.line(ww_melt_df, x="date", y="value", color='variable', title="Worldwide Confirmed/Death Cases Over Time") fig.show()

世界確診和死亡數(shù)

fig = px.line(ww_melt_df, x="date", y="value", color='variable',title="Worldwide Confirmed/Death Cases Over Time (Log scale)",log_y=True) fig.show()

世界確診和死亡數(shù)(取對數(shù))

國家(地區(qū))增長

fig = px.bar(top_country_melt_df.iloc[::-1],x='value',y='country',color='variable',barmode='group',title=f'Confirmed Cases/Deaths on {target_date}',text='value',height=1500,orientation='h') fig.show()

確診數(shù)和死亡數(shù)

top30_countries = top_country_df.sort_values('confirmed', ascending=False).iloc[:30]['country'].unique() top30_countries_df = country_df[country_df['country'].isin(top30_countries)] fig = px.line(top30_countries_df,x='date',y='confirmed',color='country',title=f'Confirmed Cases for top 30 country as of {target_date}') fig.show()

死亡最多的國家

fig = px.bar(top_country_df[:30].iloc[::-1],x='mortality_rate',y='country',title=f'Mortality rate HIGH: top 30 countries on {target_date}',text='mortality_rate',height=800,orientation='h') fig.show()

死亡率最高的國家

省份情況

出現(xiàn)新冠肺炎的主要國家的各省(州)的清單

放大美國:現(xiàn)在美國正在發(fā)生什么?

fig = px.choropleth(train_us_latest,locations='province_code',locationmode="USA-states",color='confirmed',scope="usa",hover_data=['province', 'fatalities', 'mortality_rate'],title=f'Confirmed cases in US on {target_date}') fig.show()

美國的死亡率情況

train_us_march = train_us.query('date > "2020-03-01"') fig = px.line(train_us_march,x='date', y='confirmed', color='province',title=f'Confirmed cases by state in US, as of {target_date}') fig.show()

美國各州的確診數(shù)

歐洲

fig = px.choropleth(train_europe_latest,locations="country",locationmode='country names',color="confirmed",hover_name="country",range_color=[1, train_europe_latest['confirmed'].max()],color_continuous_scale='portland',title=f'European Countries with Confirmed Cases as of {target_date}',scope='europe',height=800) fig.show()

歐洲確診數(shù)

亞洲

country_latest = country_df.query('date == @target_date')fig = px.choropleth(country_latest,locations="country",locationmode='country names',color="confirmed",hover_name="country",range_color=[1, 50000],color_continuous_scale='portland',title=f'Asian Countries with Confirmed Cases as of {target_date}',scope='asia',height=800) fig.show()

亞洲確診數(shù)

top_asian_country_df = country_df[country_df['country'].isin(['China', 'Indonesia', 'Iran', 'Japan', 'Korea, South', 'Malaysia','Philippines' ])]fig = px.line(top_asian_country_df,x='date',y='new_case',color='country',title=f'DAILY NEW Confirmed cases world wide') fig.show()

亞洲每日確診數(shù)量

現(xiàn)在哪個(gè)國家正在復(fù)蘇?

fig = px.choropleth(country_latest,locations="country",locationmode='country names',color="new_case_peak_to_now_ratio",hover_name="country",range_color=[0, 1],# color_continuous_scale="peach",hover_data=['confirmed', 'fatalities', 'new_case', 'max_new_case'],title='Countries with new_case_peak_to_now_ratio') fig.show()

可以看到中國是最安全的國家了

什么時(shí)候會收斂?通過Sigmoid擬合進(jìn)行預(yù)測

plot_sigmoid_fitting(target_country_df_list,pred_df_list,title='Sigmoid fitting with all latest data')

確診數(shù)預(yù)測,美國將會達(dá)到70萬以上確診

總結(jié)

?

本文推薦一份Jupyter notebook代碼進(jìn)行了分析,把數(shù)據(jù)可視化,并對感染人數(shù)進(jìn)行了預(yù)測。

完整代碼放在github下載:

https://github.com/fengdu78/machine_learning_beginner/tree/master/covid19

往期精彩回顧適合初學(xué)者入門人工智能的路線及資料下載機(jī)器學(xué)習(xí)在線手冊深度學(xué)習(xí)在線手冊AI基礎(chǔ)下載(pdf更新到25集)本站qq群1003271085,加入微信群請回復(fù)“加群”獲取一折本站知識星球優(yōu)惠券,復(fù)制鏈接直接打開:https://t.zsxq.com/yFQV7am喜歡文章,點(diǎn)個(gè)在看

總結(jié)

以上是生活随笔為你收集整理的新冠肺炎的可视化和预测分析(附代码)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。