Skip to content

Instantly share code, notes, and snippets.

@smzn
Created February 19, 2024 00:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smzn/05f3ee7251f749e01c3856b76e4c4ca8 to your computer and use it in GitHub Desktop.
Save smzn/05f3ee7251f749e01c3856b76e4c4ca8 to your computer and use it in GitHub Desktop.
P(B | S) セキュリティ会社に連絡がいったとき、泥棒が入った確率
#P(B | S) セキュリティ会社に連絡がいったとき、泥棒が入った確率
from pgmpy.inference import VariableElimination
# 推論エンジンの作成
infer = VariableElimination(model)
# P(B | S)を求める
result = infer.query(variables=['B'], evidence={'S': 1})
probability_b_given_s = result.values[1] # B = 1の確率を取得
print("P(B = 1 | S = 1):", probability_b_given_s)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment