AI AI basics: what it is and how it got here
Machine learning explained: how software learns from examples
How machine learning works in practice: training data, patterns, predictions, and why a model that scores well in testing can still fail badly in the real world.
The short answer
- Machine learning is the process of feeding a program thousands of solved examples so it can work out the relationship between the inputs and the answer, then apply that relationship to new cases.
- The inputs are called features and the known answers are called labels, and the quality of both decides almost everything about how the finished model behaves.
- Models are always tested on data held back from training, because a model that has seen the answers will score brilliantly and teach you nothing.
- Overfitting means the model memorized quirks of the training set instead of the underlying pattern, and it is the reason strong test scores do not guarantee real world performance.
- The single most useful question to ask about any AI claim is what the system was trained on, because that determines where it works and where it silently fails.
Machine learning is what happens when you show a program thousands of examples that already have the right answer attached, and let it work out the relationship between them. Nobody writes the rule. The program finds a mathematical function that maps inputs to outputs with as few mistakes as possible across the examples, and then you apply that function to cases nobody has seen. Everything else that gets filed under artificial intelligence, from a credit decision to a chatbot, is a variation on this one idea at different scales.
One example, all the way through: predicting a house price
Say you want software that estimates what a house will sell for. You obtain the records of 50,000 completed sales in your region over the last five years. Each record has the sale price and a set of details about the property.
The details you feed in are called features. The known answer is called the label.
| Feature | Example value |
|---|---|
| Floor area | 140 square meters (1,500 square feet) |
| Bedrooms | 3 |
| Year built | 1978 |
| Distance to nearest station | 800 meters |
| Garage | yes |
| Month of sale | March 2024 |
| Label (what you are predicting) | Sale price, 412,000 dollars |
Here is the whole procedure.
- Split the 50,000 records. Around 80 percent become the training set. The remaining 20 percent are locked away as the test set and the model never sees them.
- Start the model with essentially random settings. Show it a house, let it guess, compare the guess with the real price. The gap is the error.
- Adjust the settings slightly in the direction that would have made the error smaller. This is the only thing "learning" means.
- Repeat across the training set many times over. The average error falls, quickly at first, then slowly.
- Now unlock the test set and run the model on those 10,000 houses it has never seen. That score, and only that score, tells you whether it learned anything transferable.
- Deploy it. A new listing arrives, you supply the features, the model returns a price estimate.
The same skeleton applies whether the label is a price, a category (spam or not spam) or the next word in a sentence. Change the data and the model size and you get how a language model is trained.
The three kinds of learning you will hear named
Supervised learning is the house price case: every example comes with the correct answer attached. It covers the large majority of machine learning in commercial use.
Unsupervised learning has no labels. You hand the system 50,000 customer records and ask it to group them by similarity, and it returns clusters you then have to interpret yourself. Useful for discovering structure, harder to evaluate, because there is no right answer to check against.
Reinforcement learning has no fixed examples at all. An agent acts, receives a reward or a penalty, and adjusts to earn more reward over time. It is how game playing systems are trained, and a version of it is used to tune chatbots toward answers people rate as helpful.
Overfitting: memorizing instead of learning
A model with enough capacity can drive its training error to almost zero by memorizing the individual houses rather than learning what makes a house expensive. It notices that the property on Oak Street sold for an odd amount and encodes that quirk. On the training set it looks superb. On the test set it falls apart, because none of the memorized quirks apply.
This is overfitting, and it is the central failure of the field. The signal is a large gap between training accuracy and test accuracy. The fixes are all forms of making memorization harder: more data, a smaller model, deliberately holding back part of the network during training, or simply stopping the training early while the test score is still improving.
The opposite problem, underfitting, is a model too simple to capture the pattern at all. It is easier to spot, because it performs poorly everywhere.
Distribution shift: why models quietly rot
Even a well built model assumes tomorrow resembles the data it learned from. That assumption expires.
A house price model trained on 2019 to 2024 sales has interest rates, construction costs and buyer behavior from that window baked into its weights. When rates move sharply, its estimates drift high or low across the board, and it will never mention this. A fraud model learns the patterns of the scams that existed while it was trained, and fraudsters adapt within weeks. A demand forecast built on pre pandemic shopping was useless by mid 2020.
This is distribution shift, and it is why deployed models need monitoring rather than just launching. The practical defense is to keep comparing predictions against outcomes that arrive later, and to retrain on a schedule rather than waiting for someone to complain.
The shortcut problem
Models optimize for the score you give them, not for the thing you meant. If there is an easier signal in the data that happens to correlate with the label, they will take it.
The best documented version of this comes from medical imaging. Skin lesion classifiers trained on clinical photographs turned out to be partly detecting rulers, because clinicians place a measuring ruler beside lesions they already suspect are malignant. The model scored well in testing, because the ruler correlation held in the test set too. It had learned something real about the photographs and nothing about skin.
The same pattern shows up everywhere: a model that identifies animals by the background rather than the animal, a hiring model that keys on the name of a university, a quality inspection model that reads the timestamp burned into the image. Each looks fine until the shortcut disappears. This is also one route by which bias enters AI systems, since a shortcut is often a proxy for something you were not allowed to use directly.
What to check first
When someone tells you a system is accurate, ask what it was trained on, when that data was collected, and whether the test set came from a genuinely different pool than the training set. Those three answers predict real world performance better than any headline number. If the answer to the first question is vague, where AI training data comes from explains why that vagueness is so common, and what it usually hides.
Common questions
How much data does machine learning need?
It depends on how complicated the pattern is. A model predicting one number from five clear inputs can work with a few thousand examples, while recognizing objects in photos usually needs millions. If the examples are noisy or inconsistent, no amount of them fixes it.
Can a model learn after it is deployed?
Sometimes, but usually not automatically. Most models are frozen at the moment training ends and only change when someone retrains them on newer data. Systems that update continuously exist but need careful monitoring, because they can also learn from bad inputs.
Is machine learning the same as AI?
Machine learning is the part of artificial intelligence where behavior comes from examples rather than hand written rules. It is not the whole field, but it is the part that nearly every modern AI product is built from.
Why did a tool that worked well last year get worse?
Usually because the world moved and the model did not. Prices, language, fraud tactics and customer behavior all drift away from the data the model learned on, and accuracy decays quietly rather than failing loudly.