Logistic Regression

Author: Val11011Created Nov 10, 2025Updated Mar 31, 2026

In class LogisticRegression, this line

python
self.param -= self.learning_rate * -(y - y_pred).dot(X)

indicates that the gradient is calculated as -(y-y_pred).dot(X). Apparently, a factor of 1 / n_samples is missed here.

The interesting part is that I found there is an issue about the similar problem in Regression.py. It seems that the issue has been fixed, but only for Regression.py, not LogisticRegression.py

Source: eriklindernoren/ML-From-Scratch