QLIME (Quantum Local Interpretable Model-agnostic Explanations) is a Python library for interpreting quantum neural networks using local surrogate models.
Project description
Description
This library is intended for defining regions of non-interpretability for quantum learning models. The current versions is limited in scope as it extends a specific example introdcued in the research paper: https://arxiv.org/abs/2308.11098
User guide
You can find below a sample client python script calling quantumlime.
from sklearn.model_selection import train_test_split
from sklearn.datasets import load_iris
import numpy as np
import quantumlime
# Load the Iris dataset
iris = load_iris()
# Normalize the data by subtracting the minimum value and dividing by the maximum value
iris.data = (iris.data - iris.data.min()) / iris.data.max()
# Use the first two classes of the Iris dataset only (100 of 150 data points)
X_train, X_test, Y_train, Y_test = train_test_split(
iris.data[0:100, [0, 1]],
iris.target[0:100],
test_size=0.75,
random_state=0)
a = 2.5
c = 0.25
maxiter = 1e3
shots = int(1e4)
alpha = 0.602
gamma = 0.101
f = lambda x: quantumlime.objective(x,X_train,Y_train,shots=shots) # Objective function
x0 = np.pi*np.random.randn(4)
xsol = quantumlime.spsa(f, x0, a=a, c=c,
alpha=alpha, gamma=gamma,
maxiter=maxiter, verbose=True)
# Explain the local behavior of the model
quantumlime.region_of_indecision(1,X_train,xsol, lambda x : quantumlime.qnn(x,xsol))
# Explain the local behavior of the model at a local region of value
quantumlime.region_of_indecision(2,X_train,xsol, lambda x : quantumlime.qnn(x,xsol), local_region = 0.05)
Administration Guide
Bump version
Bumping a version requires bumpver. If bumpver is not installed yet use
pip install bumpver
Bump Z in X.Y.Z
bumpver update --patch
Bump Y in X.Y.Z
bumpver update --minor
Bump X in X.Y.Z
bumpver update --major
Publish to the TEST Pypi repository
Once the version number has been properly bumped use (note your credentials must be properly setup into your $HOME/.pypirc file:
rm -rf dist/
python -m build
twine upload -r testpypi dist/*
Publish to the PROD Pypi repository
Once the version number has been properly bumped use (note your credentials must be properly setup into your $HOME/.pypirc file:
rm -rf dist/
python -m build
twine upload -r pypi dist/*
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file quantumlime-1.9.0.tar.gz.
File metadata
- Download URL: quantumlime-1.9.0.tar.gz
- Upload date:
- Size: 9.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3cd705d6269c32f02fdcf11a4c0e4d2bd56bc2e7169f6e9a481a22865310c425
|
|
| MD5 |
44e18c24f00586d53b02c34ccea34bc3
|
|
| BLAKE2b-256 |
b744ed9691e6f3bfd8f3fa332373aaf5eebaa87904510f09760fc7b94ad8fc88
|
File details
Details for the file quantumlime-1.9.0-py3-none-any.whl.
File metadata
- Download URL: quantumlime-1.9.0-py3-none-any.whl
- Upload date:
- Size: 12.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c0597a2348dea875a858411809458e56156fdda234dca3c22a89db4e207f6ca3
|
|
| MD5 |
8deb3e83c71a2261c39ad771a5841403
|
|
| BLAKE2b-256 |
12049e6e188e8a934b103643f00e3ac4dc3f67bb4e690bf4944066178d9d8a97
|