32. Features and Labels in Machine Learning
32.2 Numeric, Category and Text Features
Why. Not every column is the same kind of feature. Models treat numbers and text differently (details grow in later chapters).
What.
- Numeric features — counts, ₹ amounts, km, minutes.
- Category features — city name, payment mode, store id (limited set of labels).
- Text features — review sentences, complaint notes (need special prep; NLP block later).
How.
- List each column and mark numeric / category / text / ignore.
- For first ML models (ch33+), start with numeric (+ simple categories).
- Leave long free text for the NLP chapters unless your mentor says otherwise.
import pandas as pd
row = {
"items": 4, # numeric
"distance_km": 3.2, # numeric
"city": "Pune", # category
"payment": "UPI", # category
"note": "please call at gate", # text — later
}
print(row)
Ravindra Bagale's Tip
Pehle numeric features ni jeet. Text feature excitement pudhe. Foundation solid. Ghabru naka.