Evaluation methodology

The fraud detector and the forecaster: metrics, overfitting, validation, tuning

In this chapter, you will learn to

Tools: scikit-learn

12 exercises

Each exercise is graded automatically, in your browser. The full statements are available once you have an account.

  1. What this is for in real life

    A model that looks excellent can be useless, or dangerous. It all depends on how you grade it. - Medicine. A screening test can be wrong in two ways: miss a sick person, or alarm a healthy one. These two…

  2. Beat the champion

    Warm-up. sklearn forbidden. You work in the AI team of a bank. After months of development, your fraud detector is finally running in production: every day, it sifts through thousands of transactions and flags the…

  3. The intern's triumph

    sklearn forbidden. This morning seemed completely normal. You arrived at your desk at the Super AI Agentic Bank at 8:30, as usual. You had your coffee, as usual. But a strange feeling crosses your mind. At…

  4. Neither too much nor too little

    sklearn forbidden. The director has recovered from the trouble with the wrongly accused customers: a few refunds and negotiations later, the relationship is restored. But there is no question of it happening again.…

  5. Comparing without a threshold

    sklearn forbidden. Your risk-score detector has proven itself. The director is considering replacing it and is comparing several competing models, but he wants to decide before setting the triggering threshold…

  6. One hundred and twenty days of predictions

    sklearn allowed. The bank sponsors a sports-prediction platform that publishes a prediction every day for 12 matches from several leagues. It wants to display on its home page the success rate the in-house model…

  7. The honest verdict

    sklearn forbidden. The director wants a number to rely on: “what accuracy will your model really have on future matches?” The problem: you have few matches, and each one counts. You are provided with…

  8. Lesson: train, validation, test, the golden rule

    As soon as a number is used to make a decision, it stops being a neutral measurement. That is why a serious ML project gives its data three distinct roles: | Set | Used for | How many times | |---|---|---| |…

  9. Too Good to Be True

    An analyst colleague proudly shows you his credit-scoring model. On the bank's thousands of already-closed loan files, it guesses who defaulted with near-perfect success. He wants to plug it into new applications…

  10. Promise to the partner

    sklearn allowed. The bank is about to sell its loan-approval model to a partner network. The partner will send the applications of its own customers, people the bank has never served, and it demands in the…

  11. Lesson: learning curves

    A learning curve plots two scores as a function of the number of training examples: the score on the data the model learned from (train curve) and the score on held-out data (validation curve). It is the…

  12. Fine-Tuning

    sklearn allowed. You are given a default DecisionTreeClassifier. It fits the training data perfectly... but on test points it plateaus (~74%). Write the function train_and_predict(X_train, y_train, X_test): it…