Ravindra BagaleCourses & study guides English Track your progress

34. Logistic Regression ने Python मध्ये Classification

Data Science

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 चे नाव ठेवा

  1. y स्पष्ट labels म्हणून लिहा: उदा. IST 6 PM पर्यंत tray रिकामी तर sold_out = 1, नाहीतर 0.
  2. 6 PM आधी माहित असलेली features लिहा (morning stock, weekday, temperature).
  3. तुम्ही 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.