(threshold, num_perm, max_r, xq, false_positive_weight,
false_negative_weight)
| 28 | |
| 29 | # 为使假阳性和假阴性概率的加权和达到最小,计算最佳参数 |
| 30 | def _optimal_param(threshold, num_perm, max_r, xq, false_positive_weight, |
| 31 | false_negative_weight): |
| 32 | min_error = float("inf") |
| 33 | opt = (0, 0) |
| 34 | for b in range(1, num_perm+1): |
| 35 | for r in range(1, max_r+1): |
| 36 | if b*r > num_perm: |
| 37 | continue |
| 38 | fp = _false_positive_probability(threshold, b, r, xq) |
| 39 | fn = _false_negative_probability(threshold, b, r, xq) |
| 40 | error = fp*false_positive_weight + fn*false_negative_weight |
| 41 | if error < min_error: |
| 42 | min_error = error |
| 43 | opt = (b, r) |
| 44 | return opt |
| 45 | |
| 46 | |
| 47 | class MinHashLSHEnsemble(object): |
no test coverage detected