(type, a, b)
| 34 | |
| 35 | #计算两个列直接的u_set分数 |
| 36 | def u_set_or_sem(type, a, b): |
| 37 | if type == 'Usem': |
| 38 | #这里的set_a是一个列表,但是因为majority函数返回的是字典的key,所以不会有重复值,就用一样的名字来命名了 |
| 39 | # set_a = set(majority_classes(a)) |
| 40 | # set_b = set(majority_classes(b)) |
| 41 | if a[-1] != 0: |
| 42 | set_a = set([a[-1]]) |
| 43 | else: |
| 44 | set_a = set([]) |
| 45 | |
| 46 | if b[-1] != 0: |
| 47 | set_b = set([b[-1]]) |
| 48 | else: |
| 49 | set_b = set([]) |
| 50 | else: |
| 51 | set_a = set(a) |
| 52 | set_b = set(b) |
| 53 | |
| 54 | n_a = len(set_a) |
| 55 | n_b = len(set_b) |
| 56 | n_d = n_a + n_b |
| 57 | |
| 58 | intersection = set_a & set_b |
| 59 | intersection_list = list(intersection) |
| 60 | t = len(intersection_list) |
| 61 | |
| 62 | #计算超几何分布 |
| 63 | hypergeom_dist = hypergeom(n_d, n_a, n_b) |
| 64 | |
| 65 | #计算累积分布 |
| 66 | cdf = hypergeom_dist.cdf(t) |
| 67 | #print(hypergeom_dist.pmf(t)) |
| 68 | #print(cdf) |
| 69 | return cdf |
| 70 | |
| 71 | |
| 72 | #所有的表的所有列根据Jaccard相似性建立LSH index |
no outgoing calls
no test coverage detected