Skip to content

Instantly share code, notes, and snippets.

@smzn
Created February 18, 2024 20:39
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/e8740e624bb54e14194ade6fba22a6a4 to your computer and use it in GitHub Desktop.
Save smzn/e8740e624bb54e14194ade6fba22a6a4 to your computer and use it in GitHub Desktop.
P101 (1) P(G = 1 | W = 1)を計算:天気が晴れという条件のもとで、芝が濡れている確率
#P101 (1) P(G = 1 | W = 1)を計算:天気が晴れという条件のもとで、芝が濡れている確率
from pgmpy.inference import VariableElimination
# 推論エンジンの作成
infer = VariableElimination(model)
# P(G = 1 | W = 1)を求める
result = infer.query(variables=['G'], evidence={'W': 1})
print(result)
probability_g_given_w_1 = result.values[1] # G = 1の確率を取得
print("P(G = 1 | W = 1):", probability_g_given_w_1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment