Implementing Maximum Likelihood Estimation in Logistic Regression Using Python: Understanding BFGS Optimisation
Tuhin Das
9 min read4 hours ago
Source: Wikimedia Commons
When we use Logistic Regression in Python, we usually write something as simple as:
from sklearn.linear_model import LogisticRegression
model = LogisticRegression()
model.fit(X, y)
But what actually happens behind the scenes when we call fit() ?
How does the model estimate its coefficients? How does it decide when to stop? And what role does an optimisation algorithm play in this process?
In this article, I will build a Logistic Regression model from scratch using Python, without relying on Scikit-learn for the estimation process.
We will use Maximum Likelihood Estimation (MLE) to estimate the coefficients and BFGS as the numerical optimisation algorithm.
The objective is not just to build a working model, but to understand the mathematics behind the code.
1.…