33. sklearn सह Python मध्ये Linear Regression
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
- Split नाही. नेहमी test rows मागे ठेवा (Chapter 31).
- Leakage. Rent predict करताना future rent किंवा “final_price_paid” feature म्हणून घेऊ नका.
- चुकीचा problem प्रकार. Churn yes/no → logistic (Chapter 34), LinearRegression नाही.
- एक वन्य outlier. ₹9 lakh चा typo rent रेषा वाकवू शकतो — आधी clean करा (Chapter 9 सवय).
- 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.
Ravindra Bagale's Tip – मराठी
Model fit झाला म्हणजे तुमचा project संपला असं नाही. Test set वरचे predictions तपासा आणि ते numbers business च्या दृष्टीने योग्य वाटतात का, हेही पाहा. या दोन्ही तपासण्या झाल्यावरच तुमचा project पूर्ण होतो.
Ravindra Bagale's Tip – हिंदी
Model fit हो गया, इसका मतलब यह नहीं कि तुम्हारा project पूरा हो गया. Test set पर predictions जाँचो और यह भी देखो कि वे numbers business के हिसाब से सही लगते हैं या नहीं. इन दोनों जाँचों के बाद ही तुम्हारा project पूरा होता है.