Logistic regression model

We now define our operations in order to properly run the logistic regression. Logistic regression is typically thought of as a single equation:

However, for the sake of clarity, we can have it broken into its three main components:

  • A weight times features matrix multiplication operation
  • A summation of the weighted features and a bias term
  • Finally, the application of a sigmoid function

As such, you will find these components defined as three separate operations:

# Three-component breakdown of the Logistic Regression equation.
# Note that these feed into each other.
apply_weights = tf.matmul(input_values, weights, name="apply_weights")
add_bias = tf.add(apply_weights, biases, name="add_bias")
activation_output = tf.nn.sigmoid(add_bias, name="activation")

As we have seen previously, the function we are going to use is the logistic function, which is fed the input data after applying weights and bias. In TensorFlow, this function is implemented as the nn.sigmoid function. Effectively, it fits the weighted input with bias into a 0-100 percent curve, which is the probability function we want.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset