Skip to content
Bayanii
Lesson 1

What is a model & how training works

Before any formulas: a model is just an answer-machine the computer builds from your data. This lesson shows where it comes from — and why the way it is tested matters more than how clever it is.

A model is a formula the computer writes

Imagine a spreadsheet with a thousand rows of past house sales: size, neighborhood, age — and the price each one sold for. You could stare at it and develop a feel: "bigger sells higher, that district adds a premium". A machine-learning model is that feel, written down as a precise rule the computer worked out by itself.

The rule takes the input columns — the features — and returns its best guess for the answer column — the target. That guess is called a prediction. Nothing more mysterious than that: data in, rule learned, answers out.

Training: guess, measure, adjust, repeat

How does the computer find the rule? By trial and error, at high speed. It starts with a rough guess of a rule, uses it to predict every row in your dataset, measures how wrong those predictions were, then adjusts the rule to shrink the error. Then it does that again. And again — thousands of times — until the error stops improving.

Guess Start with a rough rule
Measure How wrong was it, row by row?
Adjust Nudge the rule to shrink the error
Repeat Until the error stops improving

That whole loop is training. When it finishes, the adjusted rule — the model — is frozen and saved. From then on it only answers; it does not keep learning on its own.

Why some data is held back

Here is the trap: a model graded on the same rows it trained on can cheat — not deliberately, but by memorizing. So before training starts, Bayanii sets part of your data aside and never shows it to the model. The saved rows are the exam; training rows are the study material.

The student analogy

A student who memorizes last year's exam answers scores 100% on every practice test — and fails the real exam. That is overfitting: mistaking memorization for understanding. The opposite failure exists too: a student who only ever answers "the average score is about 70" is too simple to be useful — that is underfitting.

Every score Bayanii shows you on a model card was earned on held-back data the model never saw during training. That is what makes the score believable.

How Bayanii avoids a lucky guess

One exam can still be lucky — maybe the held-back rows happened to be easy. So Bayanii grades each candidate model with cross-validation: the data is split into several parts, and each part takes a turn being the exam while the rest is study material. Five parts means five exams; the grade that counts is the average.

Models also have settings of their own — how deep a decision tree may grow, how fast the rule adjusts. These knobs are called hyperparameters, and instead of asking you to pick values, Bayanii tries sensible combinations for the top models and keeps whichever grades best across those same rotating exams.

The three kinds of questions

Everything above applies to all models. What changes is the kind of answer you ask for:

Regression — predict a number

A price, a duration, a quantity. "What will this house sell for?" The next lesson works one through by hand.

Classification — predict a category

Yes or no, churn or stay, A/B/C. "Will this customer cancel next month?" Lesson 3 fills in a real confusion matrix.

Forecasting — predict the future of a series

Sales next month, demand next week — where the order of rows matters. Lesson 4 shows how a model reads time.

You never have to pick an algorithm: for whichever question you ask, Bayanii trains a whole lineup of model families in parallel and keeps the one that grades best.

This lesson describes Bayanii's real pipeline in simplified terms. It is updated by hand when the pipeline changes, so wording may occasionally lag the code.