當前位置: 首頁>>代碼示例>>Python>>正文


Python Mixture.get_moments方法代碼示例

本文整理匯總了Python中bayespy.nodes.Mixture.get_moments方法的典型用法代碼示例。如果您正苦於以下問題:Python Mixture.get_moments方法的具體用法?Python Mixture.get_moments怎麽用?Python Mixture.get_moments使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在bayespy.nodes.Mixture的用法示例。


在下文中一共展示了Mixture.get_moments方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: print

# 需要導入模塊: from bayespy.nodes import Mixture [as 別名]
# 或者: from bayespy.nodes.Mixture import get_moments [as 別名]
P.initialize_from_random()
X.observe(x)

Q.update(repeat=1000)

#print(" P:")
#print( P.get_moments() )

#print(" R:")
#print( R.get_moments() )

print(" Z:")
print( Z.get_moments() )

print(" X:")
print( X.get_moments() )


bpplt.hinton(R)
#bpplt.hinton(P)
#bpplt.hinton(Z)

bpplt.pyplot.show()

#pp = pprint.PrettyPrinter(indent=4)

#pp.pprint(X)



開發者ID:rdorado79,項目名稱:nb-al,代碼行數:29,代碼來源:bayespyex.py

示例2: Categorical

# 需要導入模塊: from bayespy.nodes import Mixture [as 別名]
# 或者: from bayespy.nodes.Mixture import get_moments [as 別名]
smoking = Categorical([0.5, 0.5])

lung = Mixture(smoking, Categorical, [[0.98, 0.02], [0.25, 0.75]])

bronchitis = Mixture(smoking, Categorical, [[0.97, 0.03], [0.08, 0.92]])

xray = Mixture(tuberculosis, Mixture, lung, Categorical,
               _or([0.96, 0.04], [0.115, 0.885]))

dyspnea = Mixture(bronchitis, Mixture, tuberculosis, Mixture, lung, Categorical,
                  [_or([0.6, 0.4], [0.18, 0.82]),
                   _or([0.11, 0.89], [0.04, 0.96])])

# Mark observations
tuberculosis.observe(TRUE)
smoking.observe(FALSE)
bronchitis.observe(TRUE) # not a "chance" observation as in the original example

# Run inference
Q = VB(dyspnea, xray, bronchitis, lung, smoking, tuberculosis, asia)
Q.update(repeat=100)

# Show results
print("P(asia):", asia.get_moments()[0][TRUE])
print("P(tuberculosis):", tuberculosis.get_moments()[0][TRUE])
print("P(smoking):", smoking.get_moments()[0][TRUE])
print("P(lung):", lung.get_moments()[0][TRUE])
print("P(bronchitis):", bronchitis.get_moments()[0][TRUE])
print("P(xray):", xray.get_moments()[0][TRUE])
print("P(dyspnea):", dyspnea.get_moments()[0][TRUE])
開發者ID:BayesianHuman,項目名稱:bayespy,代碼行數:32,代碼來源:discrete_example.py


注:本文中的bayespy.nodes.Mixture.get_moments方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。