|
@@ -125,17 +125,20 @@ class BayesCombine(object):
|
|
|
|
|
|
def get_bayes_estimate(self):
|
|
|
dim_combine_lst = [[key for key in fea.keys() if key not in ['sig_pos_pct', 'sig_neg_pct']] for fea in self.dim_features]
|
|
|
-
|
|
|
self.dim_features = reduce(update_dict, self.dim_features)
|
|
|
|
|
|
for ele in product(*dim_combine_lst):
|
|
|
- prob_pos = reduce(lambda x, y: self.dim_features[x]['pos_pct'] * self.dim_features[y]['pos_pct'], ele)
|
|
|
- prob_neg = reduce(lambda x, y: self.dim_features[x]['neg_pct'] * self.dim_features[y]['neg_pct'], ele)
|
|
|
+ pos_pct_lst = [self.dim_features[key]['pos_pct'] for key in ele]
|
|
|
+ prob_pos = reduce(lambda x, y: x * y, pos_pct_lst)
|
|
|
+
|
|
|
+ neg_pct_lst = [self.dim_features[key]['neg_pct'] for key in ele]
|
|
|
+ prob_neg = reduce(lambda x, y: x * y, neg_pct_lst)
|
|
|
+
|
|
|
prob = (prob_pos * self.dim_features['sig_pos_pct']) / (prob_neg * self.dim_features['sig_neg_pct'])
|
|
|
out_dict = dict(zip([e.split('_')[0] for e in ele], [e.split('_')[-1] for e in ele]))
|
|
|
|
|
|
# TODO 调用人群预估覆盖接口,得到该组合的人群覆盖数
|
|
|
- out_dict['population_cnt'] = 1000
|
|
|
+ out_dict['crowd_coverage_cnt'] = 1000
|
|
|
|
|
|
out_dict['combine_estimate_prob'] = prob
|
|
|
out_dict['actual_prob'] = self.actual_prob
|