liveBook · Manning

Q-table

As explained in Grokking AI Algorithms, Second Edition

A Q-table is a tabular reinforcement-learning model that stores estimated values for actions in particular states.

A Q-table is a scorecard for choosing actions in reinforcement learning. Each row represents a state, each column an action, and each cell a Q-value: an estimate of how favorable that action is in that state. The table stores a score for each action, not a separate instruction naming the best one. section 10.6

Figure 10.11 An example Q-table and states that it represents
10_11

Compare the action scores across a row to see how the agent chooses for a particular state. section 10.6

Choosing a move

Imagine an agent navigating a parking-lot simulation. Its current state identifies a row of the table. The agent compares that row’s action values and usually chooses the highest-valued move. During training, it can instead try a random move, observe the reward and next state, and use that experience to improve its estimates. section 10.6 section 10.7

A simple implementation starts with an array of zeros sized by the number of states and actions. Training repeatedly runs the simulator, choosing between a table-guided and random action and learning from the result. To use the trained table, look up the current state and take its highest-valued action until the goal is reached. section 10.6 section 10.7

The table is limited to states it represents. For an unseen state, it has no learned action value and needs a fallback such as a random move. A table based only on nearby objects may work in another parking-lot layout, but its limited view can favor short-term rewards over a better route across the whole map. section 10.7

How Grokking AI Algorithms, Second Edition covers it

How deep it goes
Explains rows, columns, action selection, initialization, training, and testing, without developing a mathematical derivation.
Examples
Uses a parking-lot navigation simulation, diagrams of states and action values, and a Python training function.
What it assumes
Introduces states, actions, and Q-values through a scorecard analogy before showing a Python implementation.
What you can do after
Apply it via a Q-learning simulation to train action scores and choose moves from a trained table.
How it connects
Connects the Q-table to Q-learning, states, actions, rewards, random exploration, and neural networks as an alternative for novel states.

Also explained in

Compare how 2 books explain Q-table →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking AI Algorithms, Second Edition. The section links point to the parts of the book it draws on.