Posts

Showing posts from April, 2017

Logistic regression with Python

Image
Introduction After having mastered linear regression in the previous article , let's take a look at logistic regression. Despite its name, it is not that different from linear regression, but rather a linear model for classification achieved by using sigmoid function instead of polynomial one. Specifically we'll be using logistic function , hence the name of the regression. Don't worry, in the future articles we'll be covering the usage of other sigmoid functions as well. Implementation The implementation of logistic regression in scikit-learn can be accessed from class LogisticRegression . This implementation can fit a multiclass logistic regression with optional L1 or L2 regularization. In the next example we'll classify iris flowers according to their sepal length and width: import numpy as np import matplotlib.pyplot as plt from sklearn import linear_model, datasets # import some data to play with iris = datasets.load_iris() X = iris.data[:, :2] ...