Launch the interactive walkthrough to discover each component, including the 3D Q-Sphere Lab & Python in Colab.
Unpack the definition, scope, and spectrum of Artificial Intelligence from narrow systems to general intelligence.
| Symbol / Term | Meaning | Beginner Interpretation |
|---|---|---|
| Agent function | The decision-making program or policy inside the AI | |
| Percept history | All past and present sensory inputs received from the environment | |
| Action space | The set of possible actions the agent can choose to execute |
An autonomous vacuum receives a bumper sensor hit percept P and chooses a turn action A.
Result: Agent changes direction to avoid collision
The AI ingests data from its environment via cameras, microphones, database logs, API streams, or tactile sensors.
The incoming signals are converted into mathematical representations (vectors, embeddings, graphs) where patterns and constraints are evaluated.
An optimization algorithm or inference engine selects the action or prediction with the highest expected reward or probability of correctness.
The chosen action is executed in the environment, and the system records the resulting outcome to refine future predictions.
Problem: Safe driving requires processing thousands of visual cues, pedestrians, and traffic signals per second.
Solution: AI fuses LiDAR, radar, and computer vision inputs to predict vehicular trajectories and steer vehicles safely without human intervention.
Problem: Radiologists must review hundreds of dense CT scans daily, risking diagnostic fatigue and missed early-stage tumors.
Solution: Deep learning models trained on millions of annotated scans flag micro-nodules and anomalies with sub-millimeter precision in seconds.
Interactive activity component
Bridge classical linear regression prediction with quantum state generation using Qiskit Hadamard superposition and measurement on Aer simulator.
For Google Colab or Jupyter notebooks, run this shell command to install the required dependencies:
!pip install scikit-learn numpy qiskit qiskit-aer1 from sklearn.linear_model import LinearRegression 2 import numpy as np 3 from qiskit import QuantumCircuit 4 from qiskit_aer import Aer
from sklearn.linear_model import LinearRegression β Classical ML linear regression model
import numpy as np β Numerical vector and matrix computations
from qiskit import QuantumCircuit β Assemble quantum circuits in Qiskit
from qiskit_aer import Aer β Qiskit Aer quantum simulator backend
1 # --- Part 1: Classical Machine Learning Prediction --- 2 X = np.array([1, 2, 3, 4, 5]).reshape(-1, 1) 3 y = np.array([2, 4, 6, 8, 10]) 4 5 # Train Classical Linear Regression Model 6 model = LinearRegression() 7 model.fit(X, y) 8 prediction = model.predict([[8]]) 9 print(f"Classical ML Prediction for X=8: {prediction[0]:.1f}") 10 11 # --- Part 2: Quantum Computing 1-Qubit Circuit --- 12 qc = QuantumCircuit(1, 1) 13 qc.h(0) 14 qc.measure(0, 0) 15 16 # Simulate using Aer simulator 17 simulator = Aer.get_backend('aer_simulator') 18 job = simulator.run(qc, shots=1000) 19 result = job.result() 20 counts = result.get_counts() 21 print(f"Quantum Measurement Counts: {counts}")
# --- Part 1: Classical Machine Learning Prediction ---
Section header
X = np.array([1, 2, 3, 4, 5]).reshape(-1, 1)
Input feature data matrix (reshaped to 2D)
y = np.array([2, 4, 6, 8, 10])
Target labels following y = 2x relation
# Train Classical Linear Regression Model
Fit model to training points
model = LinearRegression()
Instantiate estimator
model.fit(X, y)
Fit line via Ordinary Least Squares
prediction = model.predict([[8]])
Predict output for X=8
print(f"Classical ML Prediction for X=8: {prediction[0]:.1f}")
Display predicted value (16.0)
# --- Part 2: Quantum Computing 1-Qubit Circuit ---
Section header
qc = QuantumCircuit(1, 1)
Allocate 1 quantum bit and 1 classical readout bit
qc.h(0)
Apply Hadamard gate to create 50/50 superposition
qc.measure(0, 0)
Projectively measure qubit 0 into classical bit 0
# Simulate using Aer simulator
Configure simulator
simulator = Aer.get_backend('aer_simulator')
Load Aer simulator
job = simulator.run(qc, shots=1000)
Execute 1,000 measurement shots
result = job.result()
Collect simulation results
counts = result.get_counts()
Extract measurement frequency distribution
print(f"Quantum Measurement Counts: {counts}")
Print outcome tally (approx 500 for 0 and 500 for 1)
Click "Copy for Colab", open Google Colab, paste into a single cell, and run.
1 # ========================================================= 2 # Lesson 1: First Steps from Classical Prediction to a One-Qubit Quantum Circuit 3 # Prepared for Google Colab (Run with Shift + Enter) 4 # ========================================================= 5 6 # Step 1: Install required packages 7 !pip install scikit-learn numpy qiskit qiskit-aer 8 9 # Step 2: Import libraries 10 from sklearn.linear_model import LinearRegression 11 import numpy as np 12 from qiskit import QuantumCircuit 13 from qiskit_aer import Aer 14 15 # Step 3: Run Demonstration 16 # --- Part 1: Classical Machine Learning Prediction --- 17 X = np.array([1, 2, 3, 4, 5]).reshape(-1, 1) 18 y = np.array([2, 4, 6, 8, 10]) 19 20 # Train Classical Linear Regression Model 21 model = LinearRegression() 22 model.fit(X, y) 23 prediction = model.predict([[8]]) 24 print(f"Classical ML Prediction for X=8: {prediction[0]:.1f}") 25 26 # --- Part 2: Quantum Computing 1-Qubit Circuit --- 27 qc = QuantumCircuit(1, 1) 28 qc.h(0) 29 qc.measure(0, 0) 30 31 # Simulate using Aer simulator 32 simulator = Aer.get_backend('aer_simulator') 33 job = simulator.run(qc, shots=1000) 34 result = job.result() 35 counts = result.get_counts() 36 print(f"Quantum Measurement Counts: {counts}")
Train a Scikit-Learn linear regression model on feature vector X and label vector y.
Evaluate unseen input X=8 to observe deterministic output y=16.0.
Construct a 1-qubit circuit and apply a Hadamard gate to put the qubit in superposition.
Execute 1,000 measurement shots on AerSimulator to demonstrate probabilistic collapse.
Classical: X=8; Quantum: QuantumCircuit(1, 1) with H gate and measurement.
Classical ML Prediction for X=8: 16.0
Quantum Measurement Counts: {'0': 512, '1': 488}Contrasts classical deterministic prediction with quantum probabilistic superposition, introducing the foundational shift from binary bits to qubits.
From Classical Prediction to a One-Qubit Quantum Circuit β Presentation by Dr. Syed Muzamil Basha.
Test your understanding with these questions. Remember, this is for learning, not examination!