Skip to content

Covalent demonstration of the QVR algorithm using a cryptocurrency time series use case

Notifications You must be signed in to change notification settings

AgnostiqHQ/Quantum-Variational-Rewinding

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Quantum Variational Rewinding for Time Series Anomaly Detection

Author: Jack S. Baker

Email: research@agnostiq.ai

This repository contains an explicit code demonstration for the Quantum Variational Rewinding (QVR) algorithm as proposed in the article https://arxiv.org/abs/2210.16438.

In this repository, you will find:

  1. A Jupyter notebook (QVR_example.ipynb) employing QVR to detect anomalous behaviour in cryptocurrency time series data (i.e, a local simulation of the cryptocurrency case in the article) and to detect anomalous behaviour in the synthetic univariate data from the article (i.e. the didactic toy example from the paper)

  2. The pre-processed data sets used in the article in ~/data/

Install instructions

1: Install the Conda environment

To run the Jupyter Notebook, you will need a new conda environment with all of the dependices.

First, clone or download this repository to your local machine.

Next, if you don't already have conda, navigate to https://conda.io/projects/conda/en/latest/user-guide/install/download.html and install the correct version for your OS for either Miniconda or Anaconda.

In a terminal window, navigate to root directory of this repo (~QuantumVariationaRewinding) and issue

conda env create -f environment.yml

This will install the QVR environment. Let's activate it

conda activate QVR

2: Starting Covalent

After successfully creating the conda environment, the Covalent server can be started as follows

covalent start

If prompted, migrate the databases

covalent db migrate

If you run into problems starting the Covalent server, please try purging Covalent

covalent purge -Hy

this will purge any old files and directories created by Covalent giving you a fresh start. This, however, should be used sparingly as it also purges the Covalent database. Once purged, try covalent start once more.

3: Launching the notebook

If you are comfortable using the newly installed environment in your own jupyter notebook extension (VSCode etc.), then you are done and can skip this step. If not, follow the below instructions to launch a standard Jupyter Notebook from the command line.

We first need to make the kernel visible to Jupyter

python -m ipykernel install --user --name=QVR

then launch the notebook

jupyter notebook

which will open a browser window in the Jupyter explorer. Navigate to the QVR_example.ipynb and click it.

From the top drop-down menu, select kernel > change kernel > QVR. You are now good to go!