Quorum is a novel quantum computing framework designed for unsupervised anomaly detection that requires no training.
Quorum/
│
├── main.py # Main execution script
├── data_bucketing.py # Data bucketing implementation
├── feature_selection.py # Feature selection algorithms
├── swap_test_circuit.py # Quantum SWAP test implementation
│
├── Ansatzes/ # Quantum circuit ansatzes
│ ├── rx_rz_ansatz.py # Ansatz using RX and RZ gates
│ ├── ry_cx_ansatz.py # Ansatz using RY and CX gates
│ └── ry_rz_ansatz.py # Ansatz using RY and RZ gates
│
├── Embedding/ # Quantum data embedding methods
│ └── range_amplitude_enc.py # Range-based amplitude encoding
│
├── Preprocessing/ # Data preprocessing modules
│ ├── goldstein_uchida_preprocess.py # Preprocessor for Goldstein-Uchida datasets
│ └── ccpp_preprocess.py # Preprocessor for Combined Cycle Power Plant dataset
│
└── Data/ # Dataset directory (not included in repository)
└── Goldstein_Uchida_datasets/
└── breast-cancer-unsupervised-ad.csv
└── letter-unsupervised-subset-ad.csv
└── pen-global-unsupervised-ad.csv
└── PowerPlant/
└── processed_ccpp_dataset.csv
- Python 3.8+
- NumPy
- pandas
- scikit-learn
- Qiskit
- Qiskit Aer
# Clone the repository
git clone https://github.com/positivetechnologylab/Quorum.git
cd Quorum
# Install dependencies from requirements.txt
pip install -r requirements.txtThe main entry point of the framework is main.py, which can be executed with command-line arguments to specify the number of qubits and decoder option:
python main.py <num_qubits> <decoder_option> [--num_threads <threads>]num_qubits: Number of qubits to use for quantum encoding (integer)decoder_option: Decoder type (1 for Qiskit's .inverse(), 2 for manual decoder)--num_threads: Optional parameter to specify the number of threads for parallel processing (default: 4)
python main.py 4 1 --num_threads 8This will run the quantum anomaly detection with 4 qubits, using decoder option 1 (Qiskit's inverse), and 8 threads for parallel execution.
Two preprocessing modules are provided:
goldstein_uchida_preprocess.py: Preprocesses datasets from the Goldstein-Uchida collectionccpp_preprocess.py: Preprocesses the Combined Cycle Power Plant dataset
Both modules normalize the data and identify anomaly indices.
The feature_selection.py module offers multiple strategies for feature selection:
- Strategy 'a': Selects top features based on PCA importance
- Strategy 'b': Selects bottom features based on PCA importance
- Strategy 'c': Selects a mix of top and bottom features
- Strategy 'd': Weighted random selection based on feature importance
- Strategy 'e': Uniform random selection of features (used for experimental evaluation)
The data_bucketing.py module implements probabilistic bucketing of data points.
The range_amplitude_enc.py module provides amplitude encoding circuit structure to represent classical data as quantum states.
Three different ansatz options are provided:
rx_rz_ansatz.py: Uses RX and RZ rotation gatesry_cx_ansatz.py: Uses RY rotation gates and CX (CNOT) gatesry_rz_ansatz.py: Uses RY and RZ rotation gates
The swap_test_circuit.py implements the quantum SWAP test, which measures the similarity between two quantum states.
- Data Preprocessing: Normalize data and identify anomalies
- Feature Selection: Select features based on the specified strategy
- Data Bucketing: Group data points into buckets with a target probability of containing anomalies
- Quantum Encoding: Encode data into quantum states using amplitude encoding
- Autoencoder: Process the quantum states through a parameterized encoder-decoder circuit
- SWAP Test: Measure the similarity between input and output states
- Anomaly Detection: Identify anomalies based on the similarity measurements
The results of the execution are saved as a pickle file in the results/ directory as ensemble_res.pkl. This file contains information about:
- Buckets created during execution
- Selected features for each iteration
- Compression levels used
- Results from quantum circuit executions
The framework supports realistic noise simulation mimicking IBM's Brisbane quantum computer specifications. This can be enabled in the main script by uncommenting the appropriate simulator configuration.
Copyright © 2025 Positive Technology Lab. All rights reserved. For permissions, contact ptl@rice.edu.