Ravindra BagaleCourses & study guides English Track your progress

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

Data Science

34.3 predict_proba सोप्या भाषेत

का गरजेचे आहे. फक्त 0/1 prediction probability सांगत नाही. Ops teams अनेकदा विचारतात “किती खात्री?” — ते predict_proba आहे.

हे काय आहे. binary problems साठी predict_proba(X) दोन columns देते: class 0 आणि class 1 ची probability. Default predict P(class 1) ≥ 0.5 असताना class 1 निवडते. False alarms महाग असतील तर नंतर वेगळा cutoff निवडता येतो.

कसे करायचे.

Probabilities वाचा

  1. काही rows वर predict_proba बोलावा.
  2. Class 1 चा column पाहा.
  3. Default 0.5 threshold वर predict शी तुलना करा.
# After clf.fit(...)
proba = clf.predict_proba(X_test)
print("P(class 0), P(class 1):\n", proba.round(3))
print("predict:", clf.predict(X_test))

# Manual threshold example: flag churn if P(1) >= 0.4
p1 = proba[:, 1]
print("custom flags @0.4:", (p1 >= 0.4).astype(int))

तुम्हाला काय दिसायला हवे. 0 आणि 1 मधील probabilities. 0.5 जवळचे rows “अनिश्चित”. Threshold बदलल्याने missed churns vs जास्त alerts यात व्यापार होतो — business निर्णय, जादू नाही.

Ravindra Bagale's Tip

A probability of 0.51 does not mean the result is guaranteed. It only means the model is a little more sure than unsure. Choose your threshold based on the business cost of a wrong prediction, and do not depend only on the default value of 0.5.