34. Logistic Regression ने Python मध्ये Classification
34.1 Yes/No किंवा Category Problems का
का गरजेचे आहे. दुकाने दररोज yes/no प्रश्न विचारतात: हा order churn होईल का? हा UPI transfer risky आहे का? pedha tray संपेल का? ही उत्तरे classes आहेत, ₹ amounts नाहीत.
हे काय आहे. Classification एक category predict करते. सगळ्यात सोपा प्रकार binary: 0/1 (no/yes). Logistic regression हे sklearn मधील पहिले classic classifier आहे — नावात “regression” असले तरी महत्वाचे output class (आणि probability) आहे.
कसे करायचे.
Class problem चे नाव ठेवा
- y स्पष्ट labels म्हणून लिहा: उदा. IST 6 PM पर्यंत tray रिकामी तर sold_out = 1, नाहीतर 0.
- 6 PM आधी माहित असलेली features लिहा (morning stock, weekday, temperature).
- तुम्ही continuous ₹ total predict करत नाही हे तपासा (ते Chapter 33 होते).
import pandas as pd
orders = pd.DataFrame({
"morning_stock": [40, 25, 55, 30, 48],
"is_weekend": [0, 1, 0, 1, 0],
"sold_out": [1, 1, 0, 1, 0], # label
})
print(orders)
print("y is sold_out (class). X will be morning_stock + is_weekend.")
Ravindra Bagale's Tip
Many beginners get confused by the name “logistic regression”, because they think it predicts a number. It does not. It predicts a class, such as yes or no, and it also gives the probability of that class.
Ravindra Bagale's Tip – मराठी
“Logistic regression” हे नाव अनेक beginners ना गोंधळात टाकतं, कारण त्यांना वाटतं की हा model एखादा number predict करतो. तसं नाही. हा model yes किंवा no सारखा class predict करतो, आणि सोबत त्या class ची probability पण देतो.
Ravindra Bagale's Tip – हिंदी
“Logistic regression” नाम कई beginners को उलझा देता है, क्योंकि उन्हें लगता है कि यह कोई number predict करता है. ऐसा नहीं है. यह yes या no जैसी class predict करता है, और साथ में उस class की probability भी देता है.