Code Room
Code reviewHard
Question
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.
Learn the concepts
import joblibimport numpy as np model = joblib.load("model.pkl") # trained on scaled featuresFEATURES = ["age", "income", "tenure", "n_logins"] def predict(payload: dict): # payload is JSON from the API, e.g. {"age": 30, "income": 80000, ...} x = np.array([payload[k] for k in payload]) # take values as they come x = x.reshape(1, -1) return float(model.predict_proba(x)[0, 1])Run or narrate your approach, then ask the coach.