(precision, recall, beta=8)
return f_beta, f_beta_inv
Computes max. F_beta and max. F_{1/beta} for precision/recall pairs.

  Computes the maximum F_beta and maximum F_{1/beta} score over all pairs of
  precision/recall values. This is useful to compress a PRD plot into a single
  pair of values which correlate with precision and recall.

  For precision p and recall r, the F_beta score is defined as:
  F_beta = (1 + beta^2) * (p * r) / ((beta^2 * p) + r)

  Args:
    precision: 1D NumPy array or list of precision values in [0, 1].
    recall: 1D NumPy array or list of precision values in [0, 1].
    beta: Beta parameter. Must be positive. The default value is 8.

  Returns:
    f_beta: Maximum F_beta score.
    f_beta_inv: Maximum F_{1/beta} score.

  Raises:
    ValueError: If beta is not positive.
Computes max. F_beta and max. F_{1/beta} for precision/recall pairs.
Computes max . F_beta and max . F_ { 1 / beta } for precision / recall pairs .
def prd_to_max_f_beta_pair(precision, recall, beta=8):
  """Computes max. F_beta and max. F_{1/beta} for precision/recall pairs.

  Computes the maximum F_beta and maximum F_{1/beta} score over all pairs of
  precision/recall values. This is useful to compress a PRD plot into a single
  pair of values which correlate with precision and recall.

  For precision p and recall r, the F_beta score is defined as:
  F_beta = (1 + beta^2) * (p * r) / ((beta^2 * p) + r)

  Args:
    precision: 1D NumPy array or list of precision values in [0, 1].
    recall: 1D NumPy array or list of precision values in [0, 1].
    beta: Beta parameter. Must be positive. The default value is 8.

  Returns:
    f_beta: Maximum F_beta score.
    f_beta_inv: Maximum F_{1/beta} score.

  Raises:
    ValueError: If beta is not positive.
  """

  if not ((precision >= 0).all() and (precision <= 1).all()):
    raise ValueError('All values in precision must be in [0, 1].')
  if not ((recall >= 0).all() and (recall <= 1).all()):
    raise ValueError('All values in recall must be in [0, 1].')
  if beta <= 0:
    raise ValueError('Given parameter beta %s must be positive.' % str(beta))

  f_beta = np.max(_prd_to_f_beta(precision, recall, beta))
  f_beta_inv = np.max(_prd_to_f_beta(precision, recall, 1/beta))
  return f_beta, f_beta_inv
def prd_to_max_f_beta_pair ( precision , recall , beta = 8 ) : if not ( ( precision >= 0 ) . all ( ) and ( precision <= 1 ) . all ( ) ) : raise ValueError ( 'All values in precision must be in [0, 1].' ) if not ( ( recall >= 0 ) . all ( ) and ( recall <= 1 ) . all ( ) ) : raise ValueError ( 'All values in recall must be in [0, 1].' ) if beta <= 0 : raise ValueError ( 'Given parameter beta %s must be positive.' % str ( beta ) ) f_beta = np . max ( _prd_to_f_beta ( precision , recall , beta ) ) f_beta_inv = np . max ( _prd_to_f_beta ( precision , recall , 1 / beta ) ) return f_beta , f_beta_inv