NaN propagation masks model failure
Review this Python metric computation.
The pipeline keeps printing 'clean run' with RMSE 0.0 and the model is declared excellent. What's actually happening?
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 16 min
Mark a line and say what kind of problem it is.0 findings
1import numpy as np
2
3def rmse(y_true, y_pred):
4 # arrays may contain occasional NaN from upstream joins
5 err = y_true - y_pred
6 return np.sqrt(np.mean(err ** 2))
7
8def report(y_true, y_pred):
9 score = rmse(y_true, y_pred)
10 if np.isnan(score):
11 score = 0.0 # treat missing as perfect
12 print("clean run")
13 print("RMSE:", score)
14 return score
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.
Run or narrate your approach, then ask the coach.