Implement the PSI metric for distribution drift on a single feature.
Signature: def psi(expected: list, actual: list, n_bins: int = 10) -> float
Steps:
n_bins quantile boundaries from expectedexpected and actual using those boundaries(a_pct - e_pct) * log(a_pct / e_pct) and sumClip percentages to 1e-6 to avoid log(0).
Rule of thumb: <0.1 no shift, 0.1-0.25 moderate, >0.25 significant.
Math
Asked at
import numpy as np
def psi(...):
pass
Premium problem
Free accounts include problems #1–20. Upgrade to unlock the editor, hidden test cases, and reference solutions for every problem.
Already premium?