mapie.metrics
.kolmogorov_smirnov_p_value¶
- mapie.metrics.kolmogorov_smirnov_p_value(y_true: ndarray[Any, dtype[_ScalarType_co]], y_score: ndarray[Any, dtype[_ScalarType_co]]) float [source]¶
Compute Kolmogorov Smirnov p-value. Deduced from the corresponding statistic and CDF. It represents the probability of the observed statistic under the null hypothesis of perfect calibration.
- Parameters
- y_trueNDArray of shape (n_samples,)
An array of ground truth.
- y_scoreNDArray of shape (n_samples,)
An array of scores.
- Returns
- float
The Kolmogorov Smirnov p-value.
References
Tygert M. Calibration of P-values for calibration and for deviation of a subpopulation from the full population. arXiv preprint arXiv:2202.00100. 2022 Jan 31.
D. A. Darling. A. J. F. Siegert. The First Passage Problem for a Continuous Markov Process. Ann. Math. Statist. 24 (4) 624 - 639, December, 1953.
Examples
>>> import pandas as pd >>> from mapie.metrics import kolmogorov_smirnov_p_value >>> y_true = np.array([1, 0, 1, 0, 1, 0]) >>> y_score = np.array([0.8, 0.3, 0.5, 0.5, 0.7, 0.1]) >>> ks_p_value = kolmogorov_smirnov_p_value(y_true, y_score) >>> print(np.round(ks_p_value, 4)) 0.7857