統(tǒng)計學(xué)關(guān)我什么事?
你好,我是林驥。

# 導(dǎo)入庫from pyecharts import options as optsfrom pyecharts.charts import TreeMapfrom pyecharts.globals import ThemeType# 真命天子的概率a = 0.1# 無關(guān)路人的概率b = 1 - a# 送給真命天子的概率c = 0.425# 不送真命天子的概率d = 1 - c# 送給無關(guān)路人的概率e = 0.22# 不送無關(guān)路人的概率f = 1 - e# 定義數(shù)據(jù)data = [{"value": 100,"name": "后驗概率","children": [{"value": 100,"name": "送巧克力","children": [{"value": round(a*c/(a*c+b*e)*100,2), "name": "送給真命天子"},{"value": round(b*e/(a*c+b*e)*100,2), "name": "送給無關(guān)路人"},],}],},{"value": 100,"name": "先驗概率","children": [{"value": 100,"name": "條件概率","children": [{"value": round(a*c*100,2), "name": "送給真命天子"},{"value": round(a*d*100,2), "name": "不送真命天子"},{"value": round(b*e*100,2), "name": "送給無關(guān)路人"},{"value": round(b*f*100,2), "name": "不送無關(guān)路人"},],}],},]# 繪制矩形樹圖c = (TreeMap(init_opts=opts.InitOpts(width='800px', height='800px', theme=ThemeType.LIGHT)).add("推測送巧克力的女同事的心意",data,levels=[opts.TreeMapLevelsOpts(treemap_itemstyle_opts=opts.TreeMapItemStyleOpts(border_color="#00589F", border_width=4, gap_width=4)),opts.TreeMapLevelsOpts(color_saturation=[0.3, 0.5],treemap_itemstyle_opts=opts.TreeMapItemStyleOpts(border_color_saturation=0.7, gap_width=2, border_width=2),),opts.TreeMapLevelsOpts(color_saturation=[0.3, 0.5],treemap_itemstyle_opts=opts.TreeMapItemStyleOpts(border_color_saturation=0.6, gap_width=1),),opts.TreeMapLevelsOpts(color_saturation=[0.3, 0.5]),],).set_global_opts(title_opts=opts.TitleOpts(title="推測送巧克力的女同事的心意,她把你當(dāng)成真命天子的概率是"+'%.2f%%' % (a*c/(a*c+b*e)*100),pos_left="center", pos_top="30",)).render("推測送巧克力的女同事的心意.html"))

微軟之所以在激烈的市場競爭中勝出,正是由于采用了貝葉斯統(tǒng)計。


我的 2020 年終總結(jié)

?分享??收藏? ???? ???點贊 ?在看
評論
圖片
表情
