Explain the main idea of Logistic Regression and how to use it for classification.
Describe the sigmoid (logistic) function and how it converts a linear score into a probability.
Outline how Logistic Regression is trained using a loss function and gradient-based optimization.
Describe how a Variational Quantum Classifier (VQC) uses a quantum circuit to make predictions.
Compare Logistic Regression and VQC in terms of model structure, training, accuracy, and runtime on our dataset.
1. What is Logistic Regression?
Logistic Regression is a binary classification method.
Instead of predicting a continuous value, it predicts the probability that a sample belongs to class 1 (for example, “positive” vs “negative”, “unstable” vs “stable”).
Let's start with the input features:
X ∈ ℝᵈ: a feature vector with d features
y ∈ {0,1}: the true label
The goal of Logistic Regression is to learn a simple mathematical rule that takes our features as input and outputs a probability between 0 and 1.
2. Logistic Regression Model
Logistic Regression first computes a linear score:
where W is the weight vector (one weight per feature), and b is the bias term.
Then it passes this score through the sigmoid (logistic) function:
Here, output is interpreted as the probability that the sample is in class 1.
If the output is greater than or equal to 0.5, we predict class 1; otherwise, we predict class 0.
This model is still linear in the input space. The decision boundary that separates the two classes is a line, plane, or hyperplane, depending on how many features we have.
3. Training Logistic Regression
To train Logistic Regression, we choose parameters W and b that make the predictions match the true labels as closely as possible.
We do this by minimizing the logistic loss (cross-entropy loss) over all training samples. For a single sample, the loss can be written as:
For a dataset with n samples, the average loss (cost function) is:
A typical training loop:
Initialize w and b (often randomly or with small values).
Compute predictions for all training samples.
Compute the loss J(w,b)
Use gradient descent to update w and b to reduce the loss.
Repeat until the loss stops improving.
In the end, we have a simple, fast model that maps input features to a probability and a class label.
A Variational Quantum Classifier (VQC) is a quantum machine learning model that also performs binary classification, but it uses a quantum circuit instead of a linear function.
While Logistic Regression uses:
weights w and bias b in a linear equation,
VQC uses:
quantum gates with tunable parameters (angles), often denoted by θ
applied to qubits that encode our input data
After running the quantum circuit, we measure the qubits. The measurement results define a probability of class 1, similar to the probability output of Logistic Regression.
A typical VQC has two main parts:
Data Encoding Layer (Feature Map)
Classical features x are encoded into a quantum state. Conceptually, we can write the resulting state as
|ψ(x)⟩
This step maps classical data into a high-dimensional quantum state space using rotation gates and possibly entangling gates.
Variational (Trainable) Layer
Next, we apply a sequence of quantum gates with trainable parameters θ. The final state after encoding and variational layers can be written as
|ψ(θ,x)⟩
These parameters θ play a similar role to weights in Logistic Regression. They allow the circuit to learn complex decision boundaries by exploiting superposition and entanglement.
At the end of the circuit, we measure one or more qubits. The probability of measuring a particular outcome (for example, |1⟩ on a chosen qubit) is interpreted as the probability that the sample is in class 1.
In our lab, we will use different methods(classical machine learning and quantum machine learning) to train on the same dataset with the same loss function.