Machine Learning · AI216

Batch Learning vs Online Learning

Machine Learning Study guides

Batch learning trains on all available data at once and then stops learning; online learning trains incrementally as data arrives, in single instances or mini-batches.

A batch (offline) system is trained with all the data, then launched and no longer learns. To teach it about new data you train a new version from scratch on the full dataset (old plus new) and replace it. That is slow and heavy on resources for very large data.

An online system learns incrementally. You feed it data one instance at a time or in small groups called mini-batches. Each learning step is fast and cheap, so the system can learn on the fly, and it can also handle datasets too big to fit in memory (out-of-core learning), loading part of the data, training, and repeating.

The important parameter is the learning rate: how fast the system adapts to changing data. A high learning rate adapts quickly but forgets old data fast; a low learning rate has more inertia and is less sensitive to noise. A risk of online learning: bad data fed to the system degrades its performance, so you must monitor it.

Key points

  • Batch: train on everything, then stop; retrain from scratch for new data.
  • Online: learn step by step from single instances or mini-batches.
  • Online suits huge datasets (out-of-core) and fast-changing data.
  • Learning rate controls how quickly the system adapts versus how much it remembers.
  • Watch for bad data degrading an online system.

Worked example

A stock price predictor that must follow the market uses online learning. A model that classifies handwriting once a year from a fixed dataset can use batch learning.

Common questions

What are mini-batches?

Small random groups of instances fed to an online learning system at each step.

What happens with a high learning rate?

The system adapts rapidly to new data but also quickly forgets the old data.

Practice questions on this topic

Try these, then open the app to check your answers with explanations.

  1. If you set a high learning rate, then your system will rapidly adapt to new data, but it will also tend to quickly forget the old data
    • A. true
    • B. false
  2. In online learning, if good data is fed to the system, the system's performance will gradually decline
    • A. true
    • B. false
  3. One important parameter of online learning systems is how fast they should adapt to changing data: this is called the
    • A. learning rate
    • B. error rate
    • C. attribute
    • D. All of them are true
  4. What are instances fed to the system in online learning?
    • A. Individually
    • B. In large groups
    • C. Sequentially
    • D. Randomly
  5. According to the book, each learning step in online learning is .........
    • A. fast and cheap
    • B. slow and expensive
    • C. only possible offline on the full dataset
    • D. unable to learn about new data
  6. What are mini-batches in online learning?
    • A. Small groups of instances fed to the system
    • B. Individual instances fed to the system
    • C. Sequential instances fed to the system
    • D. Random instances fed to the system