🌐
IBM
developer.ibm.com › articles › implementing-logistic-regression-from-scratch-in-python
Implementing logistic regression from scratch in Python
Implement binary logistic regression from scratch in Python using NumPy. Learn sigmoid functions, binary cross-entropy loss, and gradient descent with real code.
🌐
Analytics Vidhya
analyticsvidhya.com › home › implementing logistic regression from scratch using python
Implementing Logistic Regression from Scratch using Python
October 14, 2024 - This article went through different parts of logistic regression and saw how we could implement it through raw python code. But if you are working on some real project, it’s better to opt for Scikitlearn rather than writing it from scratch as it is quite robust to minor inconsistencies and less time-consuming.
Discussions

Implementing a logistic regression model manually from scratch, without using any advanced library, to understand how it works
It would be interesting to see you implement the approximation and optimization algorithms yourself. The part most people find difficult is a quadratic approximation using Taylor series and the Hessian update step for the multivariate case. More on reddit.com
🌐 r/kaggle
1
5
July 26, 2022
Comprehensive Guide on Logistic Regression
Wow very in depth explanations guys. Reading through the PCA article now. More on reddit.com
🌐 r/learnmachinelearning
10
72
July 27, 2022
Logistic Regression in Python from Scratch
It’s good but you didn’t really discuss the mathematics like you said in the post. I guess it’d be better if you explained why we use the sigmoid and not another function with values between 0 and 1. Also, you could explain the choice of loss function. More on reddit.com
🌐 r/learnmachinelearning
6
83
September 5, 2020
How to make my Python code which implements Logistic Regression run faster or run it on AMD GPU?

The way to make python run faster is to not run it in python. There are curve fitting algorithms in Numpy - use them.

More on reddit.com
🌐 r/learnprogramming
2
1
September 16, 2023
🌐
Medium
medium.com › @koushikkushal95 › logistic-regression-from-scratch-dfb8527a4226
Logistic Regression From Scratch. Logistic regression is often mentioned… | by Koushik Ahmed Kushal | Medium
August 28, 2023 - The model is simple and one of the easy starters to learn about generating probabilities, classifying samples, and understanding gradient descent. This tutorial walks you through some mathematical equations and pairs them with practical examples in Python so that you can see exactly how to train your own custom binary logistic regression model. Implementing logistic regression from scratch in Python
🌐
nick becker
beckernick.github.io › logistic-regression-from-scratch
Logistic Regression from Scratch in Python - nick becker
November 5, 2016 - Like the other equation, this is really easy to implement. It’s so simple I don’t even need to wrap it into a function. Finally, I’m ready to build the model function. I’ll add in the option to calculate the model with an intercept, since it’s a good option to have. def logistic_regression(features, target, num_steps, learning_rate, add_intercept = False): if add_intercept: intercept = np.ones((features.shape[0], 1)) features = np.hstack((intercept, features)) weights = np.zeros(features.shape[1]) for step in xrange(num_steps): scores = np.dot(features, weights) predictions = sigmoid(scores) # Update weights with gradient output_error_signal = target - predictions gradient = np.dot(features.T, output_error_signal) weights += learning_rate * gradient # Print log-likelihood every so often if step % 10000 == 0: print log_likelihood(features, target, weights) return weights
🌐
Kaggle
kaggle.com › code › jagannathrk › logistic-regression-from-scratch-python
Logistic Regression from scratch - Python
Checking your browser before accessing www.kaggle.com · Click here if you are not automatically redirected after 5 seconds
Find elsewhere
🌐
Python Engineer
python-engineer.com › courses › mlfromscratch › 03_logisticregression
Logistic Regression in Python - ML From Scratch 03 - Python Engineer
https://towardsdatascience.com/logistic-regression-detailed-overview-46c4da4303bc · import numpy as np class LogisticRegression: def __init__(self, learning_rate=0.001, n_iters=1000): self.lr = learning_rate self.n_iters = n_iters self.weights = None self.bias = None def fit(self, X, y): n_samples, n_features = X.shape # init parameters self.weights = np.zeros(n_features) self.bias = 0 # gradient descent for _ in range(self.n_iters): # approximate y with linear combination of weights and x, plus bias linear_model = np.dot(X, self.weights) + self.bias # apply sigmoid function y_predicted = sel
🌐
Real Python
realpython.com › logistic-regression-python
Logistic Regression in Python – Real Python
June 26, 2023 - In this step-by-step tutorial, you'll get started with logistic regression in Python. Classification is one of the most important areas of machine learning, and logistic regression is one of its basic methods. You'll learn how to create, evaluate, and apply a model to make predictions.
🌐
Dataquest
dataquest.io › blog › logistic-regression-in-python
An Intro to Logistic Regression in Python (100+ Code Examples)
January 7, 2025 - We started by building our own logistic regression model from scratch. We used our custom regression model to learn about convexity and the importance of choosing the approprate learning rate. Finally, we used Scikit-Learn implementation of the logistic regression algorithm to learn about regularization, hyperparameter tuning, and multiclass classification.
🌐
KDnuggets
kdnuggets.com › 2019 › 10 › build-logistic-regression-model-python.html
How to Build Your Own Logistic Regression Model in Python - KDnuggets
To conclude, I demonstrated how to make a logistic regression model from scratch in python. Logistic regression is a widely used supervised machine learning technique. It is one of the best tools for statisticians, researchers and data scientists in predictive analytics.
🌐
GitHub
github.com › perborgen › LogisticRegression
GitHub - perborgen/LogisticRegression: Logistic regression from scratch in Python
Logistic regression from scratch in Python · This example uses gradient descent to fit the model. It also contains a Scikit Learn's way of doing logistic regression, so we can compare the two implementations.
Starred by 332 users
Forked by 273 users
Languages   Python 100.0% | Python 100.0%
🌐
Towards Data Science
towardsdatascience.com › home › latest › logistic regression from scratch in python
Logistic Regression From Scratch in Python | Towards Data Science
January 20, 2025 - First, we will understand the Sigmoid function, Hypothesis function, Decision Boundary, the Log Loss function and code them alongside. After that, we will apply the Gradient Descent Algorithm to find the parameters, weights and bias .
🌐
MachineLearningMastery
machinelearningmastery.com › home › blog › how to implement logistic regression from scratch in python
How To Implement Logistic Regression From Scratch in Python - MachineLearningMastery.com
December 11, 2019 - In this tutorial, you discovered how to implement logistic regression using stochastic gradient descent from scratch with Python.
🌐
Visual Studio Magazine
visualstudiomagazine.com › articles › 2023 › 01 › 18 › logistic-regression.aspx
Logistic Regression from Scratch Using Raw Python -- Visual Studio Magazine
January 18, 2023 - The model bias is initialized to zero. An alternative design is to place the weights and bias into a Python class. The code that trains the logistic regression model is presented in Listing 4.
🌐
GeeksforGeeks
geeksforgeeks.org › machine learning › ml-logistic-regression-using-python
Logistic Regression using Python - GeeksforGeeks
February 10, 2026 - This step standardizes feature values so they are on a similar scale. Logistic Regression uses gradient based optimization which is sensitive to feature magnitudes, so scaling helps the model train correctly.
🌐
Medium
dhirajkumarblog.medium.com › logistic-regression-in-python-from-scratch-5b901d72d68e
Logistic Regression Machine Learning Algorithm in Python from Scratch | by Dhiraj K | Medium
December 1, 2020 - Logistic Regression Machine Learning Algorithm in Python from Scratch Let’s understand the basics of Logistic Regression Introduction: When we are implementing Logistic Regression Machine Learning …
🌐
GitHub
github.com › tirthshah147 › Logistic-Regression
GitHub - tirthshah147/Logistic-Regression: Logistic Regression is implemented in Python from scratch without using any third-party Python libraries. Gradient descent, cost function, and other algorithms are also implemented.
Logistic Regression is implemented in Python from scratch without using any third-party Python libraries. Gradient descent, cost function, and other algorithms are also implemented. - tirthshah147/Logistic-Regression
Forked by 2 users
Languages   Jupyter Notebook 100.0% | Jupyter Notebook 100.0%
🌐
W3Schools
w3schools.com › python › python_ml_logistic_regression.asp
Python Machine Learning - Logistic Regression
Here we will be using basic logistic regression to predict a binomial variable. This means it has only two possible outcomes. In Python we have modules that will do the work for us.