Exercise

Asset price prediction

Now you can use a neural network to predict an asset price, which is a large component of quantitative financial analysis as well as risk management.

You'll use the 2005-2010 stock prices of Citibank, Goldman Sachs and J. P. Morgan to train a network to predict the price of Morgan Stanley's stock.

You'll create and train a neural network with one input layer, one output layer and two hidden layers.

Then a scatter plot will be shown to see how far the predicted Morgan Stanley prices are from their actual values over 2005-2010. (Recall that if the predictions are perfect, the resulting scatter plot will lie on the 45-degree line of the plot.)

The Sequential and Dense objects are available, as well as the prices DataFrame with investment bank prices from 2005-2010.

Instructions

100 XP
  • Set the input data to be all bank prices except Morgan Stanley, and the output data to be only Morgan Stanley's prices.
  • Create a Sequential neural network model with two Dense hidden layers: the first with 16 neurons (and three input neurons), and the second with 8 neurons.
  • Add a single Dense output layer of 1 neuron to represent Morgan Stanley's price.
  • Compile the neural network, and train it by fitting the model.