#005B Logistic Regression: Scratch vs. Scikit-Learn

#005B Logistic Regression: Scratch vs. Scikit-Learn

Logistic Regression: from scratch vs. Scikit-Learn

Let’s now compare Logistic Regression from scratch and Logistic Regression from scikit – learn. Our dataset are class 0 and class 1, which we generated randomly. The training set has 2000 examples coming from the first and second class. The test set has 1000 examples, 500 from each class. 

train and test samples logistic regression

When we plot these datasets it looks like this:

applying logistic regression on training examples

Python’s library scikit-learn hasĀ  function LogisticRegression and we will implement it on our dataset .

After training we will make predictions with this piece of code:

Confusion matrix for Sklearn Logistic Regression is:

This is a code for ploting the result of classification with Sklearn Logistic Regression.

Now we will compare results that we got in this post, and results we got with Logistic Regression form sci-kit learn.

Complete code you can see here.

In the next post we will learn how to optimize the computation time of our own implementation from scratch.

More resources on the topic:

Leave a Reply

Your email address will not be published. Required fields are marked *