ML Notes
Understanding the agent-environment interaction model, state representations, and environment design in reinforcement learning.
The fundamental loop in RL is the continuous interaction between an agent and its environment.
Agent-Environment Loop
State Representation
State: Complete description of environment configuration
Types of States
Fully Observable: Agent sees complete state
Partially Observable: Agent sees partial state
Latent: Hidden features must be learned
# Image: raw pixels, must learn features
state = image_array # shape (84, 84, 3)Action Space
Discrete: Finite set of actions
Continuous: Infinite actions in range
Hybrid: Mix of discrete and continuous
Reward Structure
Single Reward
reward = {
+1: goal reached,
-1: collision,
0: otherwise
}Shaped Reward
reward = {
+100: goal,
-50: collision,
-0.1: per step (encourage efficiency),
+5: moved towards goal
}Multi-Objective
rewards = {
'main_goal': 100,
'efficiency': -0.1, # per time step
'safety': -50 # for collision
}
# Combine with weights
total_reward = 1.0*main + 0.5*efficiency + 1.0*safetyAgent Architecture
Environment Types
Deterministic
Same action always produces same outcome:
next_state, reward = env.step(action)
# DeterministicStochastic
Same action can have different outcomes:
# Wind affects ball trajectory
next_state = stochastic_step(state, action)Episodic
Task has natural ending:
# Game: start to win/lose
episode = []
done = False
while not done:
action = agent.get_action(state)
state, reward, done, _ = env.step(action)
episode.append((state, action, reward))Continuing
No natural ending:
# Robot maintaining balance
for t in range(infinite):
action = agent.get_action(state)
state, reward, done, _ = env.step(action)Implementation Example
State Space Representations
Tabular
Discrete states indexed in table:
Linear Features
Hand-crafted features:
Neural Network
Learning features:
Summary
Key concepts:
- Agent observes state
- Takes action
- Receives reward and next state
- Updates policy
- Repeat until convergence
Exam Focus
Revise definitions, diagrams, examples, and short-answer points for Agents and Environments in RL.
Interview Use
Prepare one clear explanation, one practical example, and one common mistake for this Machine Learning topic.
Search Terms
machine-learning, machine learning, machine, learning, reinforcement, agents, and, environments
Related Machine Learning Topics