Data Splitting interview question

Preprocessing & Feature EngineeringData SplittingData Qualitymedium

A card-fraud dataset was extracted on 30 June. A transaction's label is 1 if a chargeback had arrived by the extraction date, and chargebacks can arrive up to 90 days after the transaction. The chart shows the observed fraud rate by transaction month; fraud controls did not change. How should you treat the April–June transactions when you build the train and test sets?

00.10.20.30.4JanFebMarAprMayJunTransaction monthObserved fraud rate (%)0.410.390.40.310.170.04
  1. AUse April to June as the out-of-time test set, because it is the most production-like period, and its lower fraud rate reflects the current level the model will face.
  2. BKeep April to June in training but leave it out of the test set, because label noise in training averages out over many rows, while test labels must be exact.
  3. CKeep every month and upweight the April-to-June fraud cases until each month shows the same fraud rate, because the reweighting corrects the under-counted positives.
  4. DLeave April to June out of both training and test until their 90-day window closes, because many of their frauds still carry label 0 and would mislead the model.
Show the answer and explanation

Correct answer: D, Leave April to June out of both training and test until their 90-day window closes, because many of their frauds still carry label 0 and would mislead the model.

Explanation Data Splitting

This is a label maturity (outcome window) problem. A transaction's label is final only once its whole outcome window has passed. On 30 June, transactions made after 1 April have had less than 90 days for chargebacks to arrive, so some of their frauds are still recorded as legitimate. The falling bars for April (0.31%), May (0.17%) and June (0.04%) are an artefact of the data cut, not a real drop in fraud.

The rule: keep only rows whose outcome window had fully closed by the extraction date, for training and testing. Here that means transactions up to about the end of March; April–June rows join the next refresh once they have matured.

ShortcutProblem
Recent months as the test setunlabelled frauds that the model flags count as false positives, so the metrics are distorted
Recent months in training onlythe noise is not random: it is one-sided and concentrated in recent rows, so the model learns that recent-looking patterns are safe
Upweighting the known recent fraudsthe missing frauds still carry label 0, and early-reported frauds are not representative, so reweighting cannot recover them

The same issue appears with 12-month default flags in credit, late-reported insurance claims, and churn defined as 30 days of inactivity. If recent data is essential, survival-style models or a shorter proxy label that has already matured are alternatives.

Interview tip: state the outcome window when defining the target ("chargeback within 90 days of the transaction") and set the last usable transaction date to the extraction date minus that window. A common follow-up is how to monitor such a model when labels arrive 90 days late (proxy metrics and input drift).

Practice it as a quiz

Answer this and the other free questions with instant grading, streaks and weak-topic tracking, or unlock all 4,000 questions.

More Preprocessing & Feature Engineering questions

  1. A retailer's click model has 200M impressions, 2M of them clicks. To cut training cost, you keep every click and 1 in 10 non-clicks, and give each kept…
  2. A bank vectorizes 2 million support tickets with TF-IDF over a 500,000-term vocabulary; the sparse matrix has about 100 non-zeros per row (≈ 2.4 GB in CSR…
  3. A retailer's store_id has 1,000 levels. Instead of one-hot encoding, a colleague proposes binary encoding: give each store an integer code and write that code…
  4. Your features include age (years), income (TRY) and num_logins (count), on very different scales. For which group of models is feature scaling generally…
  5. A gradient-boosted house-price model for Istanbul uses raw latitude and longitude as features. Prices are highest around a few prime districts and along the…