Represents the probability that an item falls into a classification group.

Equation

Wrap the linear hypothesis:

$$ h_\theta(x) = g(\theta^Tx) $$

It is wrapped in the Sigmoid function:

$$ g(z) = \frac{1}{1 + e^{-z}} $$

The complete equation is:

$$ h_\theta(x) = \frac{1}{1 + e^{-\theta^Tx}} $$

The sigmoid function graph shows that it stays between $y=0$ and $y=1$.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/05e15e16-046f-4b03-a449-6c1b1f65b44a/sigmoid.png

MATLAB

Vectorizing the sigmoid function is done as follows in MATLAB:

function g = sigmoid (z)

    g = 1 ./ (1 + e .^ -z);

end

These are all element-wise operators, since the end goal is to have an item for each element. Finally, you can simply do:

sigmoid(X * theta)

Which will give you the result of the hypothesis on each entry of X.