From a table to a matrix
The topic What machine learning is set the problem up with two assumptions. Every object arrives as a vector , and every training row is an independent draw from the distribution the model will meet. It ended by admitting that neither holds for raw data, and that the easiest way to break the second is to let information about the target slip into the features. This topic turns raw columns into features and shows how leakage makes a useless model look excellent.
A table of loan applications has a district name, a date, an income that some applicants left empty, a free-text purpose, and columns filled in months after the application was decided.
The goal is the object–feature matrix : one row per object, one column per feature, with the feature of object and the targets. Getting there starts with the type of each column.
| Type | Example | What a model needs |
|---|---|---|
| Numeric | income, area, number of purchases | often a scale and a transform for skew |
| Binary | owns a car | nothing: 0 or 1 |
| Categorical (nominal) | district, product, browser | an encoding; the categories have no order |
| Ordinal | education level, rating 1–5 | the order, but not necessarily equal steps |
| Date and time | application date | parts (hour, weekday, month) and differences ("days since") |
| Text, sets | loan purpose, tags | a vector, for example word counts |
The type decides which arithmetic is meaningful. The mean of two browsers is not a browser. Store Chrome, Firefox and Safari as 1, 2, 3, and a model that multiplies the column by a weight will treat those codes as amounts. Text becomes a vector of word counts, a bag of words: an object–feature matrix with thousands of mostly zero columns. The course NLP builds it properly.