我正在尝试计算P(A=a|B=b,C=c)
where a
is an element in ['high', 'medium', 'low']
, b is an element in['0-20', '20-40', '40-60', '60-80', '80-inf']
并且c
is an element in的条件概率['male', 'female']
。
我有一本字典,其频率如下:
{('high', '0-20', 'female'): 11,
('high', '0-20', 'male'): 43,
('high', '20-40', 'female'): 10,
('high', '20-40', 'male'): 17,
('high', '40-60', 'female'): 11,
('high', '40-60', 'male'): 10,
('high', '60-80', 'female'): 2,
('high', '60-80', 'male'): 1,
('high', '80-inf', 'female'): 0,
('high', '80-inf', 'male'): 0,
('low', '0-20', 'female'): 130,
('low', '0-20', 'male'): 159,
('low', '20-40', 'female'): 186,
('low', '20-40', 'male'): 297,
('low', '40-60', 'female'): 71,
('low', '40-60', 'male'): 144,
('low', '60-80', 'female'): 35,
('low', '60-80', 'male'): 53,
('low', '80-inf', 'female'): 1,
('low', '80-inf', 'male'): 2,
('medium', '0-20', 'female'): 90,
('medium', '0-20', 'male'): 194,
('medium', '20-40', 'female'): 72,
('medium', '20-40', 'male'): 116,
('medium', '40-60', 'female'): 46,
('medium', '40-60', 'male'): 49,
('medium', '60-80', 'female'): 12,
('medium', '60-80', 'male'): 22,
('medium', '80-inf', 'female'): 1,
('medium', '80-inf', 'male'): 2}
我想要的是一个看起来像这样的字典:
{('high', '0-20', 'female'): P(A='high'| B='0-20', C='female'),
etc...,
}