Created
February 18, 2024 20:39
-
-
Save smzn/e8740e624bb54e14194ade6fba22a6a4 to your computer and use it in GitHub Desktop.
P101 (1) P(G = 1 | W = 1)を計算:天気が晴れという条件のもとで、芝が濡れている確率
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
#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