32. Machine Learning मध्ये Features आणि Labels
32.1 Features (X) आणि Labels (y) सोप्या भाषेत
का गरजेचे आहे. sklearn code X आणि y लिहितो. ही अक्षरे स्पष्ट न वाटत असतील तर इथे थांबा — X म्हणजे inputs, y म्हणजे predict करायचे उत्तर.
हे काय आहे.
- Features (X) — model ला पाहण्याची परवानगी असलेले input columns (items, distance, rain…).
- Label (y) — अंदाज करायचा answer column (was_late, amount, churn…).
Memory trick: X = eXplanatory inputs. y = predict करायचा target (y).
कसे करायचे.
import pandas as pd
df = pd.DataFrame({
"items": [2, 5, 3],
"distance_km": [1.2, 4.0, 2.5],
"was_late": [0, 1, 0],
})
X = df[["items", "distance_km"]] # features
y = df["was_late"] # label
print("X columns:", list(X.columns))
print("y name:", y.name)
Ravindra Bagale's Tip
In the first cell of your notebook, clearly set X as the feature columns and y as the label column you want to predict. Do not depend only on column numbers with df.iloc, because it is very easy to pick the wrong column. Use clear column names, so anyone who reads your notebook knows what goes into the model.
Ravindra Bagale's Tip – मराठी
तुमच्या notebook च्या पहिल्या cell मध्ये X म्हणजे feature columns आणि y म्हणजे predict करायचा label column स्पष्टपणे ठरवा. फक्त df.iloc मधल्या column क्रमांकांवर अवलंबून राहू नका, कारण चुकीचा column निवडला जाणं खूप सोपं असतं. Column ची स्पष्ट नावं वापरा, म्हणजे notebook वाचणाऱ्या कोणालाही model मध्ये काय जातं ते लगेच कळेल.
Ravindra Bagale's Tip – हिंदी
अपने notebook के पहले cell में X यानी feature columns और y यानी predict करने वाला label column साफ़-साफ़ तय करो. सिर्फ़ df.iloc के column नंबरों पर भरोसा मत करो, क्योंकि गलत column चुन लेना बहुत आसान है. Columns के साफ़ नाम इस्तेमाल करो, ताकि notebook पढ़ने वाले हर किसी को पता चले कि model में क्या जा रहा है.