Skip to content

Commit

Permalink
Integrated quantum bayesian inference (#717)
Browse files Browse the repository at this point in the history
* Added quantum Bayesian inference

* Allowed inference with no evidence

* Passed inference test

* Passed inference test

* Works with AmplitudeProblem algorithm

* Run GroverOperator until it matches all evidence

* Quantum rejection sampling with GroverOperator

* Quantum Bayesian inference

* Started QBayesian tutorial

* QBayesian tutorial + debugging order in inference()

* Add best_qc and docs

* Added Pachinko in Tut as Bayesian network

* Bug in Pachinko game

* Add Burglary Earthquake Example

* Bug with 13 tut jupyter file

* Bug fix with 13 tut jupyter file

* Bug fix example step 5 tut 13

* Reversed index for quantum circuit variables

* Fixed QBayesian classical qubit order for query variables

* Prepared release

* Made trivial test less strict

* Fixed format errors

* Updated pylint

* Included types for dict and set for format

* Fixed spelling error from an unchanged file

* Fixed tutorial and code based on feedback

* Fixed format

* Removed shots

* Fixed format

* Adjusted format for documentation + added format result

* Added test if converged for tutorial

* Revert commit on tutorial 07

* Embedded tutorial images

* Fixed release note format

* Added images and removed base64 for images

* Added images and removed base64 for images

* Fixed documentation QBayesian

* Added Copyright 2024

* Update qiskit_machine_learning/algorithms/__init__.py

* Update releasenotes/notes/add-quantum-bayesian-inference-92c6025432d9b7e0.yaml

Co-authored-by: Steve Wood <[email protected]>

* Update releasenotes/notes/add-quantum-bayesian-inference-92c6025432d9b7e0.yaml

Co-authored-by: Steve Wood <[email protected]>

* Update qiskit_machine_learning/algorithms/inference/qbayesian.py

Co-authored-by: Declan Millar <[email protected]>

* Added tests for getter and setter

* Rerun notebook for |: 'ABCMeta' and 'NoneType'

* Added default sampler parameter

* Fixed format error release note

* Removed mutable object as a default parameter

* Fixed TypeError

---------

Co-authored-by: Peter Röseler <[email protected]>
Co-authored-by: Anton Dekusar <[email protected]>
Co-authored-by: Steve Wood <[email protected]>
Co-authored-by: M. Emre Sahin <[email protected]>
Co-authored-by: Edoardo Altamura <[email protected]>
Co-authored-by: Declan Millar <[email protected]>
  • Loading branch information
7 people authored May 20, 2024
1 parent 848d0d6 commit 91473a2
Show file tree
Hide file tree
Showing 11 changed files with 1,441 additions and 2 deletions.
21 changes: 21 additions & 0 deletions .pylintdict
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
acyclic
adam
adjoint
aer
Expand All @@ -18,13 +19,17 @@ autosummary
backend
backends
backpropagation
bayes
bayesian
benchmarking
bergholm
bitstring
bitstrings
bivariate
bloch
bool
boolean
borujeni
cargs
carlo
cbit
Expand Down Expand Up @@ -83,15 +88,19 @@ farrokh
fidelities
fidelityquantumkernel
formatter
frac
frontend
func
gambetta
gaussian
gellmann
getter
gpu
grover
guang
guzik
hamiltonian
hao
hashable
havlíček
hilbert
Expand All @@ -106,6 +115,8 @@ inlier
inplace
instantiation
instantiations
interdependencies
isaac
isometry
iten
iterable
Expand All @@ -124,6 +135,7 @@ langle
lukin
macos
makefile
mary
matmul
matplotlib
maxiter
Expand All @@ -141,6 +153,7 @@ multioutput
mxd
mypy
nat
nbsphinx
ndarray
nielsen
nn
Expand Down Expand Up @@ -191,6 +204,9 @@ qae
qarg
qargs
qasm
qb
qbayesian
qbi
qc
qgan
qgans
Expand All @@ -205,6 +221,7 @@ qubits
rangle
rbf
readme
recalibration
regressor
regressors
regs
Expand All @@ -226,6 +243,7 @@ shalev
shende
shwartz
sigmoid
sima
sklearn
softmax
sparsearray
Expand All @@ -235,6 +253,7 @@ stdlib
stdlib
stdout
str
subclasses
subcircuits
submodules
subobjects
Expand All @@ -248,6 +267,7 @@ temme
tensored
terra
th
theodore
toctree
todo
traceback
Expand Down Expand Up @@ -280,6 +300,7 @@ vz
wikipedia
williams
wrt
yoder
zoufal
zsh
θ
Binary file added docs/images/Burglary_Alarm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/Two_Node_Bayesian_Network.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
747 changes: 747 additions & 0 deletions docs/tutorials/13_quantum_bayesian_inference.ipynb

Large diffs are not rendered by default.

14 changes: 13 additions & 1 deletion qiskit_machine_learning/algorithms/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This code is part of a Qiskit project.
#
# (C) Copyright IBM 2021, 2023.
# (C) Copyright IBM 2021, 2024.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
Expand Down Expand Up @@ -56,6 +56,16 @@
NeuralNetworkClassifier
VQC
Inference
+++++++++++
Algorithms for inference.
.. autosummary::
:toctree: ../stubs/
:nosignatures:
QBayesian
Regressors
++++++++++
Algorithms for data regression.
Expand All @@ -78,6 +88,7 @@
OneHotObjectiveFunction,
)
from .classifiers import QSVC, PegasosQSVC, VQC, NeuralNetworkClassifier
from .inference import QBayesian
from .regressors import QSVR, VQR, NeuralNetworkRegressor

__all__ = [
Expand All @@ -94,4 +105,5 @@
"QSVR",
"NeuralNetworkRegressor",
"VQR",
"QBayesian",
]
18 changes: 18 additions & 0 deletions qiskit_machine_learning/algorithms/inference/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# This code is part of a Qiskit project.
#
# (C) Copyright IBM 2023, 2024.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

""" Inference Package """


from .qbayesian import QBayesian

__all__ = ["QBayesian"]
Loading

0 comments on commit 91473a2

Please sign in to comment.