Skip to content

Get P-A plot intersection point

get_pa_intersection(true_positive_rate_values, proportion_of_area_values, threshold_values)

Calculate the intersection point for prediction rate and area curves in (P-A plot).

Threshold_values values act as x-axis for both curves. Prediction rate curve uses true positive rate for y-axis. Area curve uses inverted proportion of area as y-axis.

Parameters:

Name Type Description Default
true_positive_rate_values Union[ndarray, Series]

True positive rate values, values should be within range 0-1.

required
proportion_of_area_values Union[ndarray, Series]

Proportion of area values, values should be within range 0-1.

required
threshold_values Union[ndarray, Series]

Threshold values that were used to calculate true positive rate and proportion of area.

required

Returns:

Type Description
Tuple[float, float]

X and y coordinates of the intersection point.

Raises:

Type Description
InvalidParameterValueException

true_positive_rate_values or proportion_of_area_values values are out of bounds.

Source code in eis_toolkit/validation/get_pa_intersection.py
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
@beartype
def get_pa_intersection(
    true_positive_rate_values: Union[np.ndarray, pd.Series],
    proportion_of_area_values: Union[np.ndarray, pd.Series],
    threshold_values: Union[np.ndarray, pd.Series],
) -> Tuple[float, float]:
    """Calculate the intersection point for prediction rate and area curves in (P-A plot).

    Threshold_values values act as x-axis for both curves. Prediction rate curve uses true positive rate for y-axis.
    Area curve uses inverted proportion of area as y-axis.

    Args:
        true_positive_rate_values: True positive rate values, values should be within range 0-1.
        proportion_of_area_values: Proportion of area values, values should be within range 0-1.
        threshold_values: Threshold values that were used to calculate true positive rate and proportion of area.

    Returns:
        X and y coordinates of the intersection point.

    Raises:
        InvalidParameterValueException: true_positive_rate_values or proportion_of_area_values values are out of bounds.
    """
    if true_positive_rate_values.max() > 1 or true_positive_rate_values.min() < 0:
        raise InvalidParameterValueException("true_positive_rate_values values should be within range 0-1")

    if proportion_of_area_values.max() > 1 or proportion_of_area_values.min() < 0:
        raise InvalidParameterValueException("proportion_of_area_values values should be within range 0-1")

    intersection = _get_pa_intersection(
        true_positive_rate_values=true_positive_rate_values,
        proportion_of_area_values=proportion_of_area_values,
        threshold_values=threshold_values,
    )

    return intersection.x, intersection.y