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