Session Ready
Exercise

Build and fit a simple neural net

The next model we will learn how to use is a neural network. Neural nets can capture complex interactions between variables, but are difficult to set up and understand. Recently, they have been beating human experts in many fields, including image recognition and gaming (check out AlphaGo) -- so they have great potential to perform well.

To build our nets we'll use the keras library. This is a high-level API that allows us to quickly make neural nets, yet still exercise a lot of control over the design. The first thing we'll do is create almost the simplest net possible -- a 3-layer net that takes our inputs and predicts a single value. Much like the sklearn models, keras models have a .fit() method that takes arguments of (features, targets).

Instructions
100 XP
  • Create a dense layer with 20 nodes and the ReLU ('relu') activation as the 2\(^{nd}\) layer in the neural network.
  • Create the last dense layer with 1 node and a linear activation (activation='linear').
  • Fit the model to the scaled_train_features and train_targets.