33. sklearn सह Python मध्ये Linear Regression
33.2 Fit, Intercept आणि Coefficient Intuition
का गरजेचे आहे. fit बोलावण्यापूर्वी model काय शिकतोय ते माहित हवे: सुरुवातीची value (intercept) आणि feature हलले की y किती बदलतो (coefficients).
हे काय आहे. एका feature साठी: ŷ = intercept + coef × x. Intercept म्हणजे x = 0 असताना model चा अंदाज (बहुधा खरे flat नसते — math anchor समजा). आमच्या rent story मध्ये coef = “प्रत्येक extra sqft मागे ₹ बदल”.
कसे करायचे.
रेषा कल्पना करा
- X-axis वर area, Y-axis वर rent plot करा (किंवा कल्पना करा).
- रेषा intercept येथे Y-axis ओलांडते.
- रेषेचा कल म्हणजे coefficient.
- Training errors लहान करण्यासाठी sklearn intercept आणि coef निवडते (least squares — इथे हाताने derive करायचे नाही).
# Intuition only — numbers made up for teaching
intercept = 3000 # ₹ when area is 0 (math only)
coef = 20 # about ₹20 extra rent per sqft
area = 800
guess = intercept + coef * area
print("Guess rent for 800 sqft:", guess)
तुम्हाला काय दिसायला हवे. 19000. खरा fit अनेक rows वरून चांगले numbers शोधेल. Multi-feature models मध्ये X मधील प्रत्येक column साठी एक coef येतो.
Ravindra Bagale's Tip
Do not worry if the intercept looks strange or is close to zero. The intercept is the prediction when the feature is 0, and in real life a feature value of 0 often does not happen at all. Focus on the coefficient instead, and check whether it is positive or negative to see which way the prediction moves.
Ravindra Bagale's Tip – मराठी
Intercept विचित्र दिसला किंवा 0 च्या जवळ आला तरी काळजी करू नका. Feature ची value 0 असताना model जे predict करतो तो intercept असतो, आणि खऱ्या आयुष्यात feature ची value 0 असणं अनेकदा शक्यच नसतं. त्याऐवजी coefficient वर लक्ष द्या, आणि prediction कोणत्या दिशेने बदलतं हे समजण्यासाठी तो positive आहे की negative ते पाहा.
Ravindra Bagale's Tip – हिंदी
Intercept अजीब दिखे या 0 के पास हो, तो भी चिंता मत करो. Feature की value 0 होने पर model जो predict करता है, वही intercept है, और असल ज़िंदगी में feature की value 0 होना अक्सर मुमकिन ही नहीं होता. इसकी जगह coefficient पर ध्यान दो, और prediction किस दिशा में बदलता है यह समझने के लिए देखो कि वह positive है या negative.