Let's start with an introduction to the logistic function (which is more commonly referred to as the sigmoid function) as the algorithm core before we dive into the algorithm itself. It basically maps an input to an output of a value between 0 and 1, and is defined as follows:
We can visualize what it looks like by performing the following steps:
- Define the logistic function:
>>> import numpy as np>>> def sigmoid(input):... return 1.0 / (1 + np.exp(-input))
- Input variables from -8 to 8, and the corresponding output, as follows:
>>> z = np.linspace(-8, 8, 1000)>>> y = sigmoid(z)>>> import matplotlib.pyplot ...