Updating a machine learning model's brain in real-time, one data point at a time.
Most machine learning models are trained in Batch Mode. You collect 100 million photos of cats, run a massive supercomputer for a week, and produce a finished model. If you want to teach it a new trick, you have to retrain the entire model from scratch. Online Learning is different. The model lives in production and learns continuously on the fly. As soon as a user clicks a button, the model instantly updates its internal weights based on that single interaction. It is constantly adapting to new trends minute-by-minute without ever needing a supercomputer reboot.
Instead of waiting for a batch of 10,000 examples, Online Learning uses algorithms (like SGD) that can perform a tiny "learning step" based on a batch size of 1. It compares its prediction to reality, calculates the error, and slightly nudges its internal numbers to be more accurate next time.
# Standard Batch Learning (Slow, runs nightly)
model = build_model()
model.fit(massive_historical_database)
deploy(model)
# Online Learning (Fast, runs in production)
model = load_production_model()
def on_user_interaction(ad_shown, user_clicked):
# The model made a prediction earlier.
# Now we know the GROUND TRUTH (they clicked or didn't).
# We update the model using just this 1 data point.
X_single = extract_features(ad_shown)
y_single = [1 if user_clicked else 0]
# partial_fit updates the weights slightly without starting over
model.partial_fit(X_single, y_single)
Online models are incredibly fragile. If a botnet attacks your website and clicks 10,000 random ads, your Online Learning model will instantly learn that "random clicking is normal human behavior". It will ruin itself in minutes. Batch models are much safer because you can manually clean and verify the data before training.