Machine Learning and Artificial Intelligence
The Relationship Between Artificial Intelligence, Machine Learning, and Deep Learning
Imagine a Russian nesting doll: a large doll contains a medium doll, and the medium doll contains a small doll. The relationship between artificial intelligence, machine learning, and deep learning is just like this:
- Artificial Intelligence (AI): The largest doll, the broadest concept
- Machine Learning (ML): The middle doll, a part of AI
- Deep Learning (DL): The smallest doll, a part of machine learning

What is Artificial Intelligence (AI)?
Artificial Intelligenceis a broad concept that refers to technologies that enable machines to exhibit human-like intelligence. Just as human intelligence includes abilities such as reasoning, learning, perception, and language understanding, AI also attempts to equip machines with these capabilities.
The Goals of AI:
- Simulate human thought processes
- Solve tasks that require human intelligence to accomplish
- Surpass human capabilities in certain areas
Examples of AI:
- Chess-playing programs (such as AlphaGo)
- Voice assistants (such as Siri, Xiao Ai)
- Self-driving cars
The Position of Machine Learning (ML) in AI
Machine Learningis one method of achieving artificial intelligence, but not the only one. Just as there are multiple ways to cook (stir-frying, boiling, steaming, roasting), there are also multiple approaches to implementing AI.
Characteristics of Machine Learning:
- Does not require manually writing all rules
- Automatically learns patterns from data
- Suitable for handling complex problems where rules are difficult to define explicitly
Traditional AI vs Machine Learning:
| Traditional AI Approach | Machine Learning Approach |
|---|---|
| Expert systems: manually written rules | Learning rules from data |
| Logical reasoning: based on explicit rules | Pattern recognition: finding patterns from data |
| Suitable for problems with well-defined 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 many layers)
- Particularly suitable for processing unstructured data such as images, audio, and text
- Requires large amounts of data and computational resources
Development History and Evolution

- Early AI (1950s-1970s): Mainly relied on manually written rules and logical reasoning
- Rise of Machine Learning (1980s-2000s): Began learning from data, but features required manual design
- Deep Learning Era (2010s-present): Automatically learns features, handles more complex problems

Example
Let's use a simple example to demonstrate the differences between traditional methods, machine learning, and deep learning - attempting to recognize handwritten digits.
Method 1: Traditional Approach (Rule-Based)
Example
# This is only a conceptual example; in practice, this method performs very poorly
def recognize_digit_by_rules(image):
"""
Recognizing digits based on manual rules (simplified example)
"""
# Rule 1: Count the number of black pixels in the image
black_pixels = count_black_pixels(image)
# Rule 2: Calculate the centroid position 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: rules are difficult to cover all cases, and are very fragile
Method 2: Machine Learning Approach
Example
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import accuracy_score
# 1. Manually design features (this is the limitation of traditional machine learning)
def extract_features(image):
"""
Manually designed features
"""
features = []
# Feature 1: proportion of black pixels
features.append(count_black_pixels(image) / total_pixels)
# Feature 2: image centroid
center_x, center_y = calculate_center(image)
features.extend([center_x, center_y])
# Feature 3: edge density
features.append(calculate_edge_density(image))
# ... more manually 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. Test
X_test = [extract_features(img) for img in test_images]
predictions = model.predict(X_test)
print(f"Accuracy: {accuracy_score(test_labels, predictions):.2f}")
Method 3: Deep Learning Approach
Example
import tensorflow as tf
from tensorflow.keras import layers, models
# 1. Build a neural network
model = models.Sequential([
# Automatically learns low-level features (edges, textures, etc.)
layers.Conv2D(32, (3, 3), activation='relu', input_shape=(28, 28, 1)),
layers.MaxPooling2D((2, 2)),
# Automatically learns mid-level features (shapes, combinations, etc.)
layers.Conv2D(64, (3, 3), activation='relu'),
layers.MaxPooling2D((2, 2)),
# Automatically learns 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 categories
])
# 2. Compile the model
model.compile(optimizer='adam',
loss='sparse_categorical_crossentropy',
metrics=['accuracy'])
# 3. Train directly with raw image data (no need for manually designed features)
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)
print(f"Deep learning model accuracy: {test_acc:.2f}")
Comparison of Running Results:
- Traditional method: accuracy about 60-70% (and complex rules)
- Machine learning: accuracy about 85-92% (requires manually designed features)
- Deep learning: accuracy about 98-99% (automatically learns features)