Skip to content

rachelsohzc/Simple-stock-prediction-with-ANN

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stock price prediction using MLP, RNN, and LSTM

Notes: I'm planning to work on an extension of this project. Consider this a foundation building project.

Overview and motivation

The task of predicting stock market prices is challenging. Stock prediction is of interest to most investors due to its high volatility. Even now, some investors use a combination of technical and fundamental analysis to help them make better decisions about their equity market investments. A newly popular method many investors have been using is artificial networks. Therefore, this project aims to find out which ANN model has the best performance.

Image1

Description

This is an academic project for ST311. The updated dataset for this project can be found here. This code was last run on 3rd May 2022 with this version of the dataset.

How to run

Improvements

  • Bigger sliding window for longer-term data
  • Predictions for more number of days (e.g. one month's worth of predictions instead of one)
  • Need to experiment with more ANN structures (e.g. hidden layers, combinations of concepts, types of layers)
  • A more complex model including external factors apart from prices alone (could use live news)

Conclusion

I found that I had control over various variables for each model. But what I decided to adjust was the number of epochs, number of neurons in the hidden layer, learning rates, window size, and dropout probability. It was challenging to make a comparison given the differences in the models. The prediction vs actual prices plots indicated that all our models performed well apart from the second MLP model. But by using RMSE to judge the accuracy, I concluded that the LSTM model outperformed the RNN model while the RNN model outperformed the MLP model. However, I understand how the results may be completely different if I tried the same models on different datasets, or changed up the structures slightly.

References

  1. Linear regression vs ANN in stock prediction - part 1
  2. Linear regression vs ANN in stock prediction - part 2
  3. Deep learning - part 1
  4. Deep learning - part 2
  5. Deep learning - part 3
  6. Neural networks
  7. Activation functions
  8. Activation functions study
  9. Activation functions list
  10. Saddle point problem
  11. Weight initializations
  12. Inheriting classes
  13. Dataloaders in Pytorch
  14. Normalising data - part 1
  15. Normalising data - part 2
  16. Measuring accuracy
  17. MLP model building
  18. Hidden layer structures
  19. MLP in stock prediction prices - part 1
  20. MLP in stock prediction - part 2
  21. MLP in short-term predictions
  22. Sliding window method - part 1
  23. Sliding window method - part 2
  24. Recurrent neural networks introduction
  25. RNN models in prediction
  26. Pytorch RNN implementation - part 1
  27. Pytorch RNN implementation - part 2
  28. RNN back propagation
  29. RNNs and the vanishing gradient problem - part 1
  30. RNN and the vanishing gradient - part 2
  31. RNN and LSTM concepts
  32. LSTM applications
  33. LSTM concepts - part 1
  34. LSTM concepts - part 2
  35. LSTM concepts - part 3
  36. LSTM units
  37. LSTM and GRU concepts
  38. Pytorch LSTM implementation