This repository presents a hybrid quantum-classical machine learning approach to time series forecasting, integrating classical machine learning techniques with quantum circuits. This project aims to explore the potential of quantum machine learning (QML) in predictive analytics, offering a novel solution for complex forecasting challenges.
Currently, the project works with two models: the classical LSTM model and its hybrid quantum-classical analog called HQCLSTM from this paper; the models are compared on the AAPL Stock dataset.
├── data/ # Datasets used in the project
├── evaluation/ # Saved results of model evaluation
├── models/ # Saved trained models
├── src/ # Source code
│ └── qml_time_series.ipynb # Main Jupyter notebook
├── training/ # Saved results of model training
├── LICENSE.md # License file
└── README.md # Project README fileTo simply browse the project, you can view the main Jupyter notebook here on GitHub, on Google Colab, or locally.
To run and edit the project, the easiest way to get started is to import the repository to Google Colab following these steps.
- Get a copy of the project:
git cloneit or download and unpack the .zip archive. - Save the project to your Google Drive:
- Using the web interface: use the 'folder upload' function.
- Using the app: save the project to a folder that is synced with your drive.
- Open the main Jupyter notebook on Google Colab:
- Open the 'Recent' or 'Google Drive' tab
- Search for
qml_time_series.ipynb - Open the notebook.
Colab is the preferred option because of how importing the ML packages works and how much computational power is needed to train the models, especially the quantum ones. Running everything locally may be possible, but I have not tested it and cannot offer any support in case you try to do it.
The core of this project is in the main Jupyter notebook. It covers data loading, preprocessing, model architecture (both classical and quantum), training, evaluation, and result visualization.
All prerequisite libraries are installed at the beginning of the notebook, most notably including:
- TensorFlow and scikit-learn for working with classical ML models
- TensorFlow Quantum for working with quantum ML models
- Cirq for working with quantum circuits
- SymPy for handling symbolic math
- pandas, NumPy for storing and analyzing datasets
- pickle for serializing data
- seaborn, matplotlib for visualizing data
Colab may require you to restart the session and re-run the notebook to make sure all dependencies are installed properly.
This project is licensed under the MIT License - see the LICENSE file for details.