Machine Learning and Artificial Intelligence
The Relationship Among AI, Machine Learning, and Deep Learning
Imagine Russian nesting dolls: a large doll containing a medium one, which contains a small one. The relationship among AI, machine learning, and deep learning is just like that:
- Artificial Intelligence (AI): the largest doll, the broadest concept
- Machine Learning (ML): the middle doll, part of AI
- Deep Learning (DL): the smallest doll, part of machine learning

What Is Artificial Intelligence (AI)?
Artificial Intelligenceis a broad concept referring to technologies that make machines exhibit human-like intelligence. Just as human intelligence includes abilities such as reasoning, learning, perception, and language understanding, AI tries to give machines these abilities as well.
Goals of AI:
- Simulate human thought processes
- Solve tasks that require human intelligence
- Surpass human capabilities in certain areas
Examples of AI:
- Chess-playing programs (such as AlphaGo)
- Voice assistants (such as Siri and XiaoAI)
- Self-driving cars
The Place of Machine Learning (ML) in AI
Machine learningis one approach to achieving artificial intelligence, but not the only one. Just as cooking can be done in many ways (stir-frying, boiling, steaming, roasting), there are multiple routes to AI.
Characteristics of Machine Learning:
- No need to write all the rules by hand
- Automatically learn patterns from data
- Well suited to complex problems whose rules are hard to define
Traditional AI vs Machine Learning:
| Traditional AI methods | Machine learning methods |
|---|---|
| Expert systems: manually written rules | Learn rules from data |
| Logical reasoning: based on explicit rules | Pattern recognition: find patterns in data |
| Suitable for problems with clear rules | Suitable for complex, ambiguous problems |
Deep Learning (DL) and Machine Learning
Deep learningis a branch of machine learning that uses multi-layer neural networks to learn complex patterns in data.
Characteristics of Deep Learning:
- Uses multi-layer neural networks ("deep" refers to having many layers)
- Particularly suited to unstructured data such as images, sound, and text
- Requires large amounts of data and computing resources
History and Evolution

- Early AI (1950s-1970s): relied mainly on manually written rules and logical reasoning
- The Rise of Machine Learning (1980s-2000s): began learning from data, but features still had to be designed by hand
- The Deep Learning Era (2010s-present): automatically learns features and handles more complex problems

Example
Let's use a simple example to show the differences among traditional methods, machine learning, and deep learning, by trying to recognize handwritten digits.
Method 1: Traditional Approach (Rule-Based)
Example
Traditional approach: recognize handwritten digits based on manually designed rules
This is only a conceptual example; in practice this approach performs poorly
def
recognize_digit_by_rules
(
image
)
:
"""
Recognizing digits based on manual rules (simplified example)
"""
Rule 1: Count the black pixels in the image
black_pixels
=
count_black_pixels
(
image
)
Rule 2: Compute the center of mass of the image
center_x
,
center_y
=
calculate_center
(
image
)
Rule 3: Detect specific shape features
has_circle
=
detect_circle
(
image
)
has_straight_line
=
detect_straight_line
(
image
)
Rule-based judgment
if
has_circle
and
black_pixels
<
50
:
return
"0"
elif
has_straight_line
and
center_y
<
image_height/
2:
return
"7"
... more rules
else
:
return
"Unable to recognize"
Problem: the rules are hard to cover every case with, and very fragile
Method 2: Machine Learning Approach
Example
Machine learning approach: traditional feature extraction + classifier
from
sklearn.
ensemble
import
RandomForestClassifier
from
sklearn.
metrics
import
accuracy_score
1. Design features by hand (this is the limitation of traditional machine learning)
def
extract_features
(
image
)
:
"""
Manually designed features
"""
features
=
[
]
Feature 1: ratio of black pixels
features.
append
(
count_black_pixels
(
image
)
/ total_pixels
)
Feature 2: image center of mass
center_x
,
center_y
=
calculate_center
(
image
)
features.
extend
(
[
center_x
,
center_y
]
)
Feature 3: edge density
features.
append
(
calculate_edge_density
(
image
)
)
... more hand-designed features
return
features
2. Extract features from all training data
X_train
=
[
extract_features
(
img
)
for
img
in
train_images
]
y_train
=
train_labels
3. Train the model
model
=
RandomForestClassifier
(
n_estimators
=
100
)
model.
fit
(
X_train
,
y_train
)
4. Testing
X_test
=
[
extract_features
(
img
)
for
img
in
test_images
]
predictions
=
model.
predict
(
X_test
)
(
f
"Accuracy: {accuracy_score(test_labels, predictions):.2f}"
)
Method 3: Deep Learning Approach
Example
Deep learning approach: end-to-end learning with automatic feature extraction
import
tensorflow
as
tf
from
tensorflow.
keras
import
layers
,
models
1. Build the neural network
model
=
models.
Sequential
(
[
Automatically learn low-level features (edges, textures, etc.)
layers.
Conv2D
(
32
,
(
3
,
3
)
,
activation
=
'relu'
,
input_shape
=
(
28
,
28
,
1
)
)
,
layers.
MaxPooling2D
(
(
2
,
2
)
)
,
Automatically learn mid-level features (shapes, combinations, etc.)
layers.
Conv2D
(
64
,
(
3
,
3
)
,
activation
=
'relu'
)
,
layers.
MaxPooling2D
(
(
2
,
2
)
)
,
Automatically learn high-level features (overall patterns)
layers.
Conv2D
(
64
,
(
3
,
3
)
,
activation
=
'relu'
)
,
Classification layer
layers.
Flatten
(
)
,
layers.
Dense
(
64
,
activation
=
'relu'
)
,
layers.
Dense
(
10
,
activation
=
'softmax'
)
10 digit classes
]
)
2. Compile the model
model.
compile
(
optimizer
=
'adam'
,
loss
=
'sparse_categorical_crossentropy'
,
metrics
=
[
'accuracy'
]
)
3. Train directly on raw image data (no manual feature design needed)
model.
fit
(
train_images
,
train_labels
,
epochs
=
5
,
validation_data
=
(
test_images
,
test_labels
)
)
4. Evaluate
test_loss
,
test_acc
=
model.
evaluate
(
test_images
,
test_labels
)
(
f
"Deep learning model accuracy: {test_acc:.2f}"
)
Comparison of Results:
- Traditional method: about 60-70% accuracy (and complex rules)
- Machine learning: about 85-92% accuracy (requires manually designed features)
- Deep learning: about 98-99% accuracy (features learned automatically)