Lesson 2.2~15 min

Introduction to Machine Learning

Module 2: Fundamentals of AI and Machine Learning

Introduction to Machine Learning

Machine Learning (ML) is the engine that powers most modern AI agents. It allows agents to learn from data rather than being explicitly programmed.

Why Agents Need ML

  • Environments are too complex for hand-coded rules
  • Patterns in data are too subtle for humans to specify
  • Agents need to adapt to changing conditions
  • ML enables generalization from examples

Supervised Learning

Learn from labeled examples (input → correct output).

  • Classification: Predict a category (spam/not spam, cat/dog)
  • Regression: Predict a number (house price, temperature)
# Simple supervised learning example

from sklearn.ensemble import RandomForestClassifier

# Training data: features → labels

X_train = [[0, 0], [1, 1], [2, 2], [3, 3]]

y_train = [0, 0, 1, 1]

# Train model

model = RandomForestClassifier()

model.fit(X_train, y_train)

# Predict

prediction = model.predict([[1.5, 1.5]]) # → 0 or 1

Unsupervised Learning

Find patterns in data without labels.

  • Clustering: Group similar items (customer segments)
  • Dimensionality reduction: Compress data while preserving structure
  • Anomaly detection: Find unusual patterns

Reinforcement Learning

Learn by trial and error with rewards and penalties.

  • Agent takes actions in an environment
  • Receives rewards or penalties
  • Learns a policy that maximizes cumulative reward
  • Most relevant to AI agent development!
# Reinforcement learning concept

# Agent learns: state → action mapping (policy)

# Goal: maximize total reward over time

# Q-learning update rule:

# Q(s, a) = Q(s, a) + α * (reward + γ * max(Q(s', a')) - Q(s, a))

When to Use Which

ParadigmUse WhenAgent Example
SupervisedHave labeled dataSpam filter agent
UnsupervisedNeed to find structureCustomer segmentation agent
ReinforcementAgent interacts with environmentGame-playing agent

Key Takeaways

  • ML enables agents to learn from experience rather than following fixed rules
  • Supervised learning needs labeled data; unsupervised finds patterns; RL learns from rewards
  • Reinforcement learning is the most natural fit for agent development
  • Modern agents often combine multiple ML paradigms

Test Your Knowledge

5 randomized questions from a pool of 10. Pass with 60% to unlock the next lesson.