Code Room
Code reviewMediumcr-g623
Subject Ml evaluationLevel Mid–Senior~16 minCommon in ML systems interviewsIndustries Software development

Question

Review this Python fraud-detection evaluation.

The model prints 99.51% accuracy. Should it ship?

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.

Talk through your review
Code to reviewpython
import numpy as npfrom sklearn.ensemble import RandomForestClassifierfrom sklearn.metrics import accuracy_score # y: 0 = legit, 1 = fraud; about 0.5% of rows are frauddef evaluate(X_tr, y_tr, X_te, y_te):    clf = RandomForestClassifier(n_estimators=200, random_state=0)    clf.fit(X_tr, y_tr)    preds = clf.predict(X_te)    acc = accuracy_score(y_te, preds)    print(f"accuracy: {acc:.4f}")  # prints 0.9951    if acc > 0.99:        print("shipping it")    return acc
Run or narrate your approach, then ask the coach.