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
Start with numeric features, because they are the easiest to use in a model. Add category features after that, and move to text features only when the basics work well. A strong base of simple features will help you more than a quick jump to difficult ones.
Ravindra Bagale's Tip – मराठी
सुरुवात numeric features पासून करा, कारण model मध्ये ते वापरायला सगळ्यात सोपे असतात. त्यानंतर category features जोडा, आणि basics नीट चालू लागल्यावरच text features कडे वळा. अवघड features कडे घाईने उडी मारण्यापेक्षा सोप्या features चा मजबूत पाया तुम्हाला जास्त मदत करेल.
Ravindra Bagale's Tip – हिंदी
शुरुआत numeric features से करो, क्योंकि model में इन्हें इस्तेमाल करना सबसे आसान है. उसके बाद category features जोड़ो, और basics ठीक से चलने के बाद ही text features पर जाओ. मुश्किल features पर जल्दी कूदने से ज़्यादा, आसान features की मज़बूत नींव तुम्हारी मदद करेगी.