datasketch/lshensemble.py
def _optimal_param(threshold, num_perm, max_r, xq, false_positive_weight,
        false_negative_weight):
    '''
    Compute the optimal parameters that minimizes the weighted sum
    of probabilities of false positive and false negative.
    xq is the ratio of x/q.
    '''
    min_error = float("inf")
    opt = (0, 0)
    for b in range(1, num_perm+1):
        for r in range(1, max_r+1):
            if b*r > num_perm:
                continue
            fp = _false_positive_probability(threshold, b, r, xq)
            fn = _false_negative_probability(threshold, b, r, xq)
            error = fp*false_positive_weight + fn*false_negative_weight
            if error < min_error:
                min_error = error
                opt = (b, r)
    return opt
def _optimal_param(threshold, num_perm, max_r, xq, false_positive_weight,
        false_negative_weight):
    '''
    Compute the optimal parameters that minimizes the weighted sum
    of probabilities of false positive and false negative.
    xq is the ratio of x/q.
    '''
    min_error = float("inf")
    opt = (0, 0)
    for b in range(1, num_perm+1):
        for r in range(1, max_r+1):
            if b*r > num_perm:
                continue
            fp = _false_positive_probability(threshold, b, r, xq)
            fn = _false_negative_probability(threshold, b, r, xq)
            error = fp*false_positive_weight + fn*false_negative_weight
            if error < min_error:
                min_error = error
                opt = (b, r)
    return opt
def _optimal_param ( threshold , num_perm , max_r , xq , false_positive_weight , false_negative_weight ) : min_error = float ( "inf" ) opt = ( 0 , 0 ) for b in range ( 1 , num_perm + 1 ) : for r in range ( 1 , max_r + 1 ) : if b * r > num_perm : continue fp = _false_positive_probability ( threshold , b , r , xq ) fn = _false_negative_probability ( threshold , b , r , xq ) error = fp * false_positive_weight + fn * false_negative_weight if error < min_error : min_error = error opt = ( b , r ) return opt
Compute the optimal parameters that minimizes the weighted sum
    of probabilities of false positive and false negative.
    xq is the ratio of x/q.
Compute the optimal parameters that minimizes the weighted sum of probabilities of false positive and false negative . xq is the ratio of x / q .