r"""Find the threshold level that accomplishes the desired specificity

def thresh_from_spec(spec, labels, scores, **kwargs):
    r"""Find the threshold level that accomplishes the desired specificity"""
    cost_fun.verbose = kwargs.pop('verbose', cost_fun.verbose)
    cost_fun.target = spec
    return minimize(cost_fun,
                    x0=[.5],
                    args=(labels, scores),
                    method='SLSQP',
                    constraints=({'type': 'ineq',
                                  'fun': lambda x: np.array([x[0]]),
                                  'jac': lambda x: np.array([1.])},
                                 ),
                    **kwargs
                    )