def _interpolate_prc(prc):
    """Interpolate the precision-recall curve.

    Replaces precision with interpolated precision: the maximal precision that
    can be achieved at given or higher recall.

    Parameters
    ----------
    prc : list of (confidence, precision, recall)
        Points of precision-recall curve.

    Returns
    -------
    iprc : list of (confidence, interpolated_precision, recall)

    """
    iprc = []
    interpolated_precision = 0

    for c, precision, recall in reversed(prc):
        interpolated_precision = max(precision, interpolated_precision)
        iprc.append((c, interpolated_precision, recall))

    return list(reversed(iprc))