parameters: (self, preds, target, sample_weights=None, pos_label=1)
return_statement: return fps, tps, preds[threshold_idxs]
docstring: Calculate True Positives and False Positives per binary classification threshold.
docstring_summary: Calculate True Positives and False Positives per binary classification threshold.
docstring_tokens: Calculate True Positives and False Positives per binary classification threshold .
function: def _binary_clf_curve(self, preds, target, sample_weights=None, pos_label=1):
          """Calculate True Positives and False Positives per binary classification threshold."""
          if sample_weights is not None and not isinstance(sample_weights, np.ndarray):
              sample_weights = np.array(sample_weights)
  
          if preds.ndim > target.ndim:
              preds = preds[:, 0]
          desc_score_indices = np.argsort(-preds)
  
          preds = preds[desc_score_indices]
          target = target[desc_score_indices]
  
          if sample_weights is not None:
              weight = sample_weights[desc_score_indices]
          else:
              weight = 1.
  
          distinct_value_indices = np.where(preds[1:] - preds[:-1])[0]
          threshold_idxs = np.pad(distinct_value_indices, (0, 1), constant_values=target.shape[0] - 1)
          target = np.array(target == pos_label).astype(np.int64)
          tps = np.cumsum(target * weight, axis=0)[threshold_idxs]
  
          if sample_weights is not None:
              fps = np.cumsum((1 - target) * weight, axis=0)[threshold_idxs]
          else:
              fps = 1 + threshold_idxs - tps
  
          return fps, tps, preds[threshold_idxs]
function_tokens: def _binary_clf_curve ( self , preds , target , sample_weights = None , pos_label = 1 ) : if sample_weights is not None and not isinstance ( sample_weights , np . ndarray ) : sample_weights = np . array ( sample_weights ) if preds . ndim > target . ndim : preds = preds [ : , 0 ] desc_score_indices = np . argsort ( - preds ) preds = preds [ desc_score_indices ] target = target [ desc_score_indices ] if sample_weights is not None : weight = sample_weights [ desc_score_indices ] else : weight = 1. distinct_value_indices = np . where ( preds [ 1 : ] - preds [ : - 1 ] ) [ 0 ] threshold_idxs = np . pad ( distinct_value_indices , ( 0 , 1 ) , constant_values = target . shape [ 0 ] - 1 ) target = np . array ( target == pos_label ) . astype ( np . int64 ) tps = np . cumsum ( target * weight , axis = 0 ) [ threshold_idxs ] if sample_weights is not None : fps = np . cumsum ( ( 1 - target ) * weight , axis = 0 ) [ threshold_idxs ] else : fps = 1 + threshold_idxs - tps return fps , tps , preds [ threshold_idxs ]