Giter VIP home page Giter VIP logo

sandeepadilshanalagiyawanna / softserve_qlstm Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dikshantdulal/softserve_qlstm

0.0 0.0 0.0 6.04 MB

We implement a quantum-classical hybrid QLSTM model by incorporating quantum variational layers into the classical LSTM in order to improve the efficiency and trainability of LSTM for better stock price prediction.

Python 0.94% Jupyter Notebook 99.06%

softserve_qlstm's Introduction

SoftServe_QLSTM

Introduction

Stock price prediction is one of the most rewarding problems in modern finance, where the accurate forecasting of future stock prices can yield significant profit and reduce the risks. LSTM (Long Short-Term Memory) is a recurrent Neural Network (RNN) applicable to a broad range of problems aiming to analyze or classify sequential data. Therefore, many people have used LSTM to predict the future stock price based on the historical data sequences with great success.

On the other hand, recent studies have shown that the LSTM's efficiency and trainability can be improved by replacing some of the layers in the LSTM with variational quantum layers, thus making the classical LSTM a quantum-classical hybrid model, which we will call QLSTM for Quantum LSTM. A recent study done by Samuel Yen-Chi Chen, Shinjae Yoo, and Yao-Lung L. Fang shows that QLSTM offers better trainability compared to its classical counterpart as it proved to learn significantly more information after the first training epoch than its classical counterpart and learned the local features better, all while having a comparable number of parameters. Inspired by these recent results, we proceed to test this variational quantum-classical hybrid neural network technique on stock price predictions.

In this submission, we provide a proof of concept that QLSTM can be used to predict stock prices on a particular stock (Merck and Co. Inc (MRK)), and that the results of its prediction is comparable, and perhaps even arguably better in terms of loss, to its classical counter part. We demonstrate that it has a higher trainability as the loss decreases faster with the QLSTM per epoch, and that the results were achieved using much less parameters in QLSTM as compared to the classical LSTM.

Submission

For the implementation of QLSTM and its comparison to the classical LSTM, please refer to the notebook Stock Prediction Draft 3 . It provides a proof of concept that QLSTM can be used to perform stock price predictions by training the model to predict the stock prices of Merck and Co. Inc (MRK), and that it has comparable results for its prediction to its classical counterpart while requiring much fewer parameters. Furthermore, we show that trainability of QLSTM is arguably better than LSTM.

For more in depth view of our data collection process, please refer to the notebook Data Collection . It lists our data collection decisions that provided us a relevant csv file to train the QLSTM and LSTM for the above submission.

Disclaimer: As of right now, we are testing QLSTM on the Pennylane simulator, but the technique is technology agnostic and can work on any gate based device, be it IBM's Qiskit or AWS Braket's gate based devices. We are planning to test its viability on NISQ era devices soon.

Outline of GitHub

  • Stock Prediction Draft 3 : Main notebook for this GitHub. Provides a proof of concept that QLSTM can be used to great effect for stock prices forecasting for MRK, and compares it to the classical counterpart while also performing the complexity analysis.
  • Data Collection : Describes the data collection process, and the relevant decisions made during that process.
  • Factory.py : Has the main classes used for Stock Prediction Draft 3 , including the LSTM and QLSTM classes.
  • helper.py : Has useful functions for data collection
  • dataset_MRK_prediction.csv : Main csv used for the Stock Prediction Draft 3
  • MRK.csv : MRK data, used in Data Collection
  • Other files are just images used in descriptions in Stock Prediction Draft 3

softserve_qlstm's People

Contributors

jonastyw avatar dikshantdulal avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.