Created
February 19, 2024 00:12
-
-
Save smzn/05f3ee7251f749e01c3856b76e4c4ca8 to your computer and use it in GitHub Desktop.
P(B | S) セキュリティ会社に連絡がいったとき、泥棒が入った確率
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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