Ravindra BagaleCourses & study guides English Track your progress

32. Machine Learning मध्ये Features आणि Labels

Data Science

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.