Hands-On Quantum Machine Learning With Python
Minimum price
Suggested price

Hands-On Quantum Machine Learning With Python

Volume 1: Get Started

About the Book


Hands-On Quantum Machine Learning With Python

You're interested in quantum computing and machine learning... ...But you don't know how to get started? Let me help!

Whether you just get started with quantum computing and machine learning or you're already a senior machine learning engineer, Hands-On Quantum Machine Learning With Python is your comprehensive guide to get started with Quantum Machine Learning - the use of quantum computing for the computation of machine learning algorithms.

Quantum computing promises to solve problems intractable with current computing technologies. But is it fundamentally different and asks us to change the way we think.

Hands-On Quantum Machine Learning With Python strives to be the perfect balance between theory taught in a textbook and the actual hands-on knowledge you’ll need to implement real-world solutions.

Inside this book, you will learn the basics of quantum computing and machine learning in a practical and applied manner.

Hands-On Quantum Machine Learning With Python provides a no-nonsense teaching style guaranteed to cut through all the cruft and help you master Quantum Machine Learning

Hands-on tutorials (with lots of code) that not only show you the concepts of quantum computing and the algorithms behind machine learning but their implementations as well.

Inside Hands-On Quantum Machine Learning With Python, you'll learn the basics of machine learning and quantum computing.

You'll learn how to create parameterized quantum circuits and variational hybrid quantum-classical algorithms that solve classification tasks.

Learn about quantum superposition, entanglement, and interference and how you can use it to solve problems intractable for classical computers.

Before you do anything else, take a look at the first three chapters of the book for free. You can download this preview at www.pyqml.com. This sample contains almost 100 pages that get you started with quantum machine learning.

This book offers a practical, hands-on exploration of quantum machine learning. Rather than working through tons of theory, we will build up practical intuition about the core concepts. We will acquire the exact knowledge we need to solve practical examples with lots of code. Step by step, you will extend your knowledge and learn how to solve new problems.

Of course, we will do some math. Of course, we will cover a little physics. But I don’t expect you to hold a degree in any of these two fields. We will go through all the concepts we need. While this includes some mathematical notation and formulae, we keep it at the minimum required to solve our practical problems.

The theoretical foundation of quantum machine learning may appear overwhelming at first sight.

Be assured, when put into the right context and when explained conceptually, it is not as hard as it sounds. And this is what’s inside Hands-On Quantum Machine Learning With Python.

Is this book right for me?

You don't need to be a mathematician. 

You don't need to be a physicist, either.

This book is for developers, programmers, students, and researchers who have at least some programming experience and who want to become proficient in quantum machine learning. Don’t worry if you’re just getting started with quantum computing and machine learning. We will begin with the very basics. We don’t assume prior knowledge of machine learning or quantum computing. You will not get left behind.

Of course, we will write code. A lot of code, actually. If you know a little Python, great! If you don’t know Python but another language, such as Java, Javascript, or PHP, you’ll be fine, too. If you know programming concepts (such as if-then-else-constructs and loops) then learning the syntax is a piece of cake. If you’re familiar with functional programming constructs, such as map, filter, and reduce, you’re already well equipped. If not, don’t worry, we will get you started with these constructs, too. We don’t expect you to be a senior software developer. We will go through all the code. Line by line. By the time you finish this book, you will be proficient with doing the math, understanding the physics, and writing the code you need to graduate to more advanced content.

The time you’ll save by reading through Hands-On Quantum Machine Learning With Python will more than pay for itself.


For all examples inside Hands-On Quantum Machine Learning With Python, we use Python as our programming language. Python is easy to learn. Its simple syntax allows you to concentrate on learning quantum machine learning, rather than spending your time with the specificities of the language.

The most important library we use is Qiskit. It is IBM's quantum computing SDK. Qiskit is open-source. It provides tools for creating and manipulating quantum programs and running them on prototype quantum devices on IBM Quantum Experience or on simulators on your local computer.

For all the machine learning parts, we will use Scikit-Learn. Scikit-learn is the most useful library for machine learning in Python. It contains a range of supervised and unsupervised learning algorithms. Scikit-learn builds upon a range of other very useful libraries, such as:

  • NumPy: Work with n-dimensional arrays
  • SciPy: Fundamental library for scientific computing
  • Matplotlib: Comprehensive 2D/3Dbplotting
  • IPython: Enhanced interactive console
  • Sympy: Symbolic mathematics
  • Pandas: Data structures and analysis


Inside this book, we will learn how to create actual algorithms from the scratch, such as:

  • Quantum Probabilistic Classifier
  • Quantum Bayesian Network
  • Quantum Optimization Algorithms

About the Author

Frank Zickert
Frank Zickert

I have been working as an IT professional for 15 years. I studied Information Systems Development and earned my PhD in 2012 at Goethe University of Frankfurt

Table of Contents

  • 1 Introduction
    • 1.1 Who This Book Is For
    • 1.2 Book Organization
    • 1.3 Why Should I Bother With Quantum Machine Learning?
    • 1.4 Quantum Machine Learning ‐ Beyond The Hype
    • 1.5 Quantum Machine Learning In The NISQ Era
    • 1.6 I learned Quantum Machine Learning The Hard Way
    • 1.7 Quantum Machine Learning Is Taught The Wrong Way
    • 1.8 Configuring Your Quantum Machine Learning Workstation
  • 2 Binary Classification
    • 2.1 Predicting Survival On The Titanic
    • 2.2 Get the Dataset
    • 2.3 Look at the data
    • 2.4 Data Preparation and Cleaning
    • 2.5 Baseline
    • 2.6 Classifier Evaluation and Measures
    • 2.7 Unmask the Hypocrite Classifier
  • 3 Qubit and Quantum States
    • 3.1 Exploring the Quantum States
    • 3.2 Visual Exploration Of The Qubit State
    • 3.3 Bypassing The Normalization
    • 3.4 Exploring The Observer Effect
    • 3.5 Parameterized Quantum Circuit
    • 3.6 Variational Hybrid Quantum‐Classical Algorithm
  • 4 Probabilistic Binary Classifier
    • 4.1 Towards Naïve Bayes
    • 4.2 Bayes' Theorem
    • 4.3 Gaussian Naïve Bayes
  • 5 Working with Qubits
    • 5.1 You Don't Need To Be A Mathematician
    • 5.2 Quantumic Math ‐ Are You Ready For The Red Pill?
    • 5.3 If You Want To Gamble With Quantum Computing
  • 6 Working With Multiple Qubits
    • 6.1 Hands‐On Introduction To Quantum Entanglement
    • 6.2 The Equation Einstein Could Not Believe
    • 6.3 Quantum Programming For Non‐mathematicians
  • 7 Quantum Naïve Bayes
    • 7.1 Pre‐processing
    • 7.2 PQC
    • 7.3 Post‐Processing
  • 8 Quantum Computing Is Different
    • 8.1 The No‐Cloning Theorem
    • 8.2 How To Solve A Problem With Quantum Computing
    • 8.3 The Quantum Oracle Demystified
  • 9 Quantum Bayesian Networks
    • 9.1 Bayesian Networks
    • 9.2 Composing Quantum Computing Controls
    • 9.3 Circuit implementation
  • 10 Bayesian Inference
    • 10.1 Learning Hidden Variables
    • 10.2 Estimating A Single Data Point
    • 10.3 Estimating A Variable
    • 10.4 Predict Survival
  • 11 The World Is Not A Disk
    • 11.1 The Qubit Phase
    • 11.2 Visualize The Invisible Qubit Phase
    • 11.3 Phase Kickback
    • 11.4 Quantum Amplitudes and Probabilities
  • 12 Working With The Qubit Phase
    • 12.1 The Intuition Of Grover's Algorithm
    • 12.2 Basic Amplitude Amplification
    • 12.3 Two‐Qubit Amplification
  • 13 Search For The Relatives
    • 13.1 Turning the Problem into a Circuit
    • 13.2 Multiple Results
  • 14 Sampling
    • 14.1 Forward Sampling
    • 14.2 Bayesian Rejection Sampling
    • 14.3 Quantum Rejection Sampling
  • 15 What's Next?

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

80% Royalties. Earn $16 on a $20 book.

We pay 80% royalties. That's not a typo: you earn $16 on a $20 sale. If we sell 5000 non-refunded copies of your book or course for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earnedover $13 millionwriting, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub