It is instructive to study implementations of simple logistic regression using gradient descent, but the open source community has produced fast, efficient implementations with flexible options for regularization. Scikit-learn is one of these.

The programs below vividly illustrate that the use of easily-available libraries can dramatically speed the execution of machine learning, and dramatically reduce the number of lines of code you have to write and maintain.

Logistic Regression with Scikit-learn in Python

Use pip install scikit-learn before running the Python program below:

The above program should run in less than a second and then print out values. For each of the classes, try entering its values here. When you’ve entered all the values, you will see what the model function for that class looks like.

Logistic Regression with Scikit-learn in Julia

Use Pkg.add('ScikitLearn') before running the Julia program below:

The above program should run in a few seconds and then print out values. For each of the classes, try entering its values here. When you’ve entered all the values, you will see what the model function for that class looks like.