Improving the predictions of linear models
In the preceding recipes, we have noted that the number of parameters we are fitting far exceeds the equivalent linear models. In this recipe, we will attempt to improve our logistic model of low birth weight by using a neural network.
Getting ready
For this recipe, we will load the low birth weight data and use a neural network with two hidden fully-connected layers with sigmoid activations to fit the probability of a low birth weight.
How to do it
We proceed with the recipe as follows:
- We start by loading the libraries and initializing our computational graph as follows:
import matplotlib.pyplot as plt import numpy as np import tensorflow as tf import requests sess = tf.Session()
- Next, we load, extract, and normalize our data as in the preceding recipe, except that here we are going to using the low birth weight indicator variable as our target instead of the actual birth weight, shown as follows:
# Name of data file birth_weight_file = 'birth_weight...