AI Tutorial menu

Machine Learning vs Deep Learning

AI, machine learning and deep learning are related words, but they do not mean the same thing.

Three Circles

Think of three circles, one inside the other:

  • AI is the biggest circle: any technique that makes computers act smart, including hand-written rules.
  • Machine learning (ML) is inside AI: systems that learn patterns from data.
  • Deep learning (DL) is inside ML: machine learning that uses large neural networks with many layers.

So every deep learning system is machine learning, and every machine learning system is AI, but not the other way round.

What is Machine Learning?

In machine learning, you give the computer examples (data) and the answers you want, and it finds the rule that connects them. Later it uses that rule on new data.

For example, an online shop in Karachi wants to predict delivery time from distance. It has past orders:

Example

python
from sklearn.linear_model import LinearRegression

distance_km = [[2], [5], [8], [12]]
minutes = [20, 32, 44, 60]

model = LinearRegression()
model.fit(distance_km, minutes)
print(round(model.predict([[10]])[0]))
Output
52

The model learned that each extra kilometre adds about 4 minutes, and it predicts about 52 minutes for 10 km. Nobody wrote that rule by hand.

Types of Machine Learning

TypeHow it learnsExample
Supervised learningFrom examples with correct answers (labels)Predict house price, detect spam
Unsupervised learningFinds groups or patterns without labelsGroup customers by shopping habits
Reinforcement learningLearns by trial and error with rewardsGame-playing AI, robot control

Modern chatbots use a mix: they first learn from huge amounts of text (a form of self-supervised learning), then are improved with human feedback.

What is Deep Learning?

Deep learning uses neural networks with many layers. Each layer learns a slightly more complex pattern. In a photo model, early layers find edges, middle layers find shapes like eyes and wheels, and later layers recognise whole objects like "cat" or "rickshaw".

Here is a tiny neural network in scikit-learn. It is small, but it uses the same idea:

Example

python
from sklearn.neural_network import MLPClassifier

# [hours studied, hours slept] -> passed (1) or failed (0)
X = [[1, 4], [2, 5], [6, 7], [8, 8], [3, 4], [7, 6]]
y = [0, 0, 1, 1, 0, 1]

net = MLPClassifier(hidden_layer_sizes=(8, 8), max_iter=2000, random_state=1)
net.fit(X, y)
print(net.predict([[7, 7], [1, 5]]))
Output
[1 0]

Real deep learning models have millions or billions of numbers inside them and are trained on GPUs.

Which One to Use?

Classic machine learningDeep learning
Data neededHundreds to thousands of rowsUsually very large datasets
Computer powerA normal laptopOften GPUs
Best forTables of numbers (sales, marks, prices)Images, audio, text, video
Easy to explain?Often yesUsually harder

For a spreadsheet of sales or student results, simple machine learning is often faster, cheaper and just as accurate as deep learning. Use deep learning when the data is images, sound or language.

Exercise

Exercise

Which statement is correct?

Learn AI with a teacher

Join the AI & Prompt Engineering course at Workownix, online or in Orangi Town, Karachi, and get a certificate.

See the course Ask on WhatsApp