Learning the Heater From Its Own Logs
Description and use
The author replaced a hand‑coded heater model with one trained on 4,800 logged transitions, achieving more accurate temperature predictions.
Problem
A hand‑written world‑model for a heater used arbitrary constants and was inaccurate for a real room. The model needed to learn the true dynamics from logged data.
Outcome
The trained model outperformed the hand‑coded model, predicting room temperatures more accurately on unseen data.
Workflow
- Define realRoom function with true constants and noise.
- Generate 80 episodes of 60 steps each, recording state, action, and nextState.
- Use a thermostat to decide actions, injecting random actions every fifth step.
- Collect the log of Transition objects.
- Train a new predictive model on the logged data.
- Evaluate the trained model against unseen room states.
- Run the complete system in the browser.
Evidence
The model is four numbers. The training loop is twenty lines.
Eight episodes gives 4,800 transitions, each one the Transition type from the 101 post.
The rule for the rest of the post is that nothing below this line gets to look inside realRoom.
- Record date: 2026-10-16T20:56:02.910Z