Curvingo · Made in India

Glossary

Select one of the keywords on the left…

Logistic RegressionCode with Python

Reading time: ~5 min

Here is Kavya ma'am's model in Python with scikit-learn. It looks almost the same as linear regression — only the model's name changes.

  • model.predict_proba(...) gives the chances of each group; [0][1] picks the chance of group 1, "passed".
  • model.predict(...) applies the threshold 0.5 and answers 1 or 0.

scikit-learn adds a small penalty on large weights by default (called regularisation), so its curve is a little gentler than ours: it finds w \approx 0.83 instead of 1.02. Run the program, then try a different number of hours.

The S-Curve, Without a Library

Once w and b are known, the model is only a few lines of plain Python: a straight line, then the sigmoid. Try 4.3 hours — it lands right on the decision boundary.

To reveal more content, you have to complete all the activities and exercises above. 
Are you stuck? or reveal all steps

Next up:
Summary
Sina