MODULE 07 ยท Junior+ ยท 2 hours

A weak model on strong features beats a strong model on weak ones

Building a feature matrix for credit scoring out of three tables, and stepping around the trap that makes a model look brilliant on history and collapse in production.

Open this module in the simulator All 23 lessons

The first two modules are free, no card. The rest are $20/month.

๐Ÿข The situation

Datacore's fintech arm is launching installment payments. It needs scoring: approve the application or not. Igor hands you the feature preparation:

"The model will be simple; the features are where quality is won. The industry rule: the best model on weak features loses to a simple model on strong features. You have three tables: applications, wallet transaction history, and past installment history. Build the feature matrix from them. And be careful with categories and missing values โ€” in production applications arrive messy."

๐ŸŽฏ Your task

  1. Master aggregate features from transaction history.
  2. Encode categorical features correctly.
  3. Handle missing values so it works in production too.

๐Ÿ“š Theory

What feature engineering is

Transforming raw data into features that "highlight" the task for the model. Kinds:

  1. Aggregates over history: sums, means, counts, shares over time windows (30/90/180 days).
  2. Ratios and differences: payment / income, days since last delinquency.
  3. Temporal features: day of week, account age, seasonality.
  4. Categorical encoding โ€” turning strings into numbers.
  5. Transformations: log for skewed amounts, age binning.

Encoding categorical features

Method How When
One-Hot a column per category few categories (< 15โ€“20)
Ordinal category โ†’ number categories truly ordered (education)
Target encoding category โ†’ mean target within it many categories; โš ๏ธ leakage risk โ€” compute on train only, with CV/smoothing
Frequency category โ†’ its frequency fast and often surprisingly good

โš ๏ธ Trap: one-hot for "city" with 900 values โ†’ 900 columns, a sparse matrix, overfitting to rare cities.

Missing values: think like a production engineer

Feature leakage (the main enemy of scoring)

A feature must not contain information from the future relative to the application moment. A classic failure: the feature "number of debt collector calls" โ€” it only appears for those already delinquent. A model with it shows a fantastic AUC on history and collapses in production. The rule: all features are computed strictly on data available before the application moment (point-in-time).

Point-in-time: what may and may not go into features aggregate window: 90 days BEFORE the application transactions, logins, payments โœ“ application moment THE FUTURE โ€” forbidden "collector calls", account status, the delinquency itself โ€” consequences of the target โœ— history โ†’ a feature from the future = "AUC 0.99" on history and a crash in production
Every feature must be computable at prediction time. Anything that appears after the application is leakage.

What to remember

  • Scoring quality is won with features, not with model choice.
  • Aggregates over time windows + ratios are the workhorses of tabular ML.
  • Every feature is strictly point-in-time relative to the prediction moment.
  • Missingness is information too; encode it as a flag.

Next in this module: Practice

Open the module โ†’

Nearby lessons

06 A 99%-accurate model that doesn't work 08 Churn v2: boosting vs the forest

The whole program โ€” 23 lessons