Measure train-serving distribution shift with the Population Stability Index for each feature:
PSI=i=1∑B(si−ti)ln(tisi)Here, B is the number of bins, ti is a training proportion, and si is its serving proportion. Add eps to both proportions before evaluating each term. A feature is skewed when its PSI is at least threshold. Return each PSI rounded to six decimals with its boolean skewed flag in a nested dictionary.
Input: train_dist = {"age": [0.1, 0.2, 0.3, 0.25, 0.15], "income": [0.2, 0.2, 0.2, 0.2, 0.2]}, serving_dist = {"age": [0.05, 0.1, 0.15, 0.35, 0.35], "income": [0.2, 0.2, 0.2, 0.2, 0.2]}, threshold = 0.2, eps = 1e-10
Output: {"age": {"psi": 0.411051, "skewed": true}, "income": {"psi": 0, "skewed": false}}
Explanation: The age distribution exceeds the threshold, while the identical income distributions have zero PSI.
Input: train_dist = {"clicks": [0.3, 0.4, 0.2, 0.1]}, serving_dist = {"clicks": [0.25, 0.35, 0.25, 0.15]}, threshold = 0.2, eps = 1e-10
Output: {"clicks": {"psi": 0.047223, "skewed": false}}
Convert each pair of bin lists with np.asarray(..., dtype=float) + eps.
Compute one feature with np.sum((serving - train) * np.log(serving / train)).
Sign in to take notes on this problem
Accepts: any
Accepts: any
Accepts: number
Accepts: number
Measure train-serving distribution shift with the Population Stability Index for each feature:
PSI=i=1∑B(si−ti)ln(tisi)Here, B is the number of bins, ti is a training proportion, and si is its serving proportion. Add eps to both proportions before evaluating each term. A feature is skewed when its PSI is at least threshold. Return each PSI rounded to six decimals with its boolean skewed flag in a nested dictionary.
Input: train_dist = {"age": [0.1, 0.2, 0.3, 0.25, 0.15], "income": [0.2, 0.2, 0.2, 0.2, 0.2]}, serving_dist = {"age": [0.05, 0.1, 0.15, 0.35, 0.35], "income": [0.2, 0.2, 0.2, 0.2, 0.2]}, threshold = 0.2, eps = 1e-10
Output: {"age": {"psi": 0.411051, "skewed": true}, "income": {"psi": 0, "skewed": false}}
Explanation: The age distribution exceeds the threshold, while the identical income distributions have zero PSI.
Input: train_dist = {"clicks": [0.3, 0.4, 0.2, 0.1]}, serving_dist = {"clicks": [0.25, 0.35, 0.25, 0.15]}, threshold = 0.2, eps = 1e-10
Output: {"clicks": {"psi": 0.047223, "skewed": false}}
Convert each pair of bin lists with np.asarray(..., dtype=float) + eps.
Compute one feature with np.sum((serving - train) * np.log(serving / train)).
Sign in to take notes on this problem
Accepts: any
Accepts: any
Accepts: number
Accepts: number