def specificity(classify=(lambda document: False), documents=[]):
 (TP, TN, FP, FN) = confusion_matrix(classify, documents)
 return (float(TN) / ((TN + FP) or 1))

def specificity ( classify = ( lambda document : False ) , documents = [ ] ) : ( TP , TN , FP , FN ) = confusion_matrix ( classify , documents ) return ( float ( TN ) / ( ( TN + FP ) or 1 ) )
returns the percentage of negative cases correctly classified as negative .