Ravindra BagaleCourses & study guides English Track your progress

33. sklearn सह Python मध्ये Linear Regression

Data Science

33.5 Linear Regression च्या सामान्य चुका

का गरजेचे आहे. Beginners कडे चालणारे पण business साठी चुकीचे notebook अनेकदा असते. हे सापळे लवकर ओळखा.

हे काय आहे. सामान्य linear-regression चुका: test set न ठेवता सर्व rows वर fit; label X मध्ये घालणे; गोंधळलेल्या data वर परिपूर्ण रेषा अपेक्षा; units विसरणे (₹ vs lakhs); स्पष्ट yes/no target साठी linear regression वापरणे.

कसे करायचे.

चुकांची checklist

  1. Split नाही. नेहमी test rows मागे ठेवा (Chapter 31).
  2. Leakage. Rent predict करताना future rent किंवा “final_price_paid” feature म्हणून घेऊ नका.
  3. चुकीचा problem प्रकार. Churn yes/no → logistic (Chapter 34), LinearRegression नाही.
  4. एक वन्य outlier. ₹9 lakh चा typo rent रेषा वाकवू शकतो — आधी clean करा (Chapter 9 सवय).
  5. 10 rows वर R² वर जास्त विश्वास. Tiny samples परिपूर्ण दिसतात; ती पुरावा नाहीत.
# BAD: label inside features
# X_bad = df[["area_sqft", "rent_inr"]] # never do this

# GOOD
X_good = df[["area_sqft"]]
y_good = df["rent_inr"]
assert "rent_inr" not in X_good.columns

Ravindra Bagale's Tip

Fitting the model does not mean your project is finished. You also need to check the predictions on the test set and ask whether the numbers make business sense. Your project is complete only when both of these checks are done.