Code RoomInference skips feature scaling
HardPrep Room Coding #2260

Inference skips feature scaling

Code reviewML systemsSenior–Staff~22 min

Review this Python inference handler that loads a model trained with a fitted scaler.

Offline metrics are strong but online predictions are nonsense. Find the train/serve skew bugs.

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix, specific and kind.

0:00 of about 22 min
Mark a line and say what kind of problem it is.0 findings
1import joblib
2import numpy as np
3 
4model = joblib.load("model.pkl") # trained on scaled features
5FEATURES = ["age", "income", "tenure", "n_logins"]
6 
7def predict(payload: dict):
8 # payload is JSON from the API, e.g. {"age": 30, "income": 80000, ...}
9 x = np.array([payload[k] for k in payload]) # take values as they come
10 x = x.reshape(1, -1)
11 return float(model.predict_proba(x)[0, 1])
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.