When machine became popular, there was a lot of attention given to predicting stock prices. Many different algorithms have been applied to predict stock prices, from more traditional algorithms such as random forests to the more recent extreme gradient boosting. While the latter might still outperform deep learning approaches in most cases, it can still be of valuable to use in a neural network approach. This can, for example, be used in an ensemble of networks or for multi-layer stacking. In the following recipe, we will predict stock prices with the Keras framework.
- We start by importing all the libraries, as follows:
import matplotlib.pyplot as plt import numpy as np import pandas as pd from sklearn.preprocessing import MinMaxScaler from keras.layers.core import Dense, Activation, Dropout from keras.layers.recurrent import LSTM from keras.models import Sequential
- Let's load the data and print the first rows:
data = pd.read_csv...