Training data is the set of examples an AI model uses to learn. For a spam filter, it is a pile of emails marked "spam" or "not spam". For an image tool, it is photos with labels. For a chatbot, it is a very large collection of text. A model can only learn the patterns it sees in this data. If the data is incomplete, wrong, or one-sided, the model will be too.
Where does AI learn from?
It depends on the kind of model.
In supervised learning, every example comes with the correct answer, called a label:
| Email subject | Label |
|---|---|
| "Meeting time tomorrow" | not spam |
| "You won a free vacation!" | spam |
| "Assignment due date changed" | not spam |
| "Your account is suspended, click now" | spam |
People usually add the labels. If a person makes a mistake, or two people label the same example differently, the model learns that confusion too.
Not all training data has labels. Large language models learn from text without labels. The model sees part of a text and predicts what comes next. The right answer is already in the text itself. That text comes from public web pages, books, articles, and program code.
What is the difference between training data and test data?
A good project splits its data into three parts:
| Part | Purpose | Comparison |
|---|---|---|
| Training set (70-80%) | The model learns from it | Worked examples in a textbook |
| Validation set (10-15%) | Choosing settings | Practice exams |
| Test set (10-15%) | Final check, used once | The real exam |
The percentages are common habits, not strict rules. With very large data, a smaller test set is enough. One rule never changes: the test set must contain examples the model has never seen. If students get the exam questions in advance, the exam measures memory, not learning.
Here is the simplest version: split 100 examples into a training set and a test set.
import random examples = list(range(1, 101)) random.seed(42) random.shuffle(examples) training_set = examples[:80] test_set = examples[80:] print(len(training_set), len(test_set)) print(set(training_set) & set(test_set))
The first line prints 80 20. The second line prints an empty set, set(), which shows that the two parts share no examples. Shuffling matters. If your data is sorted, for example all spam emails first, then splitting without shuffling gives two very different parts.
What happens when a model memorizes its data?
If a model scores very well on its training set but badly on new data, it memorized details instead of learning the general rule. This is called overfitting. It is like a student who memorizes only last year's exam. The same questions get full marks, but new questions cause trouble.
Here are numbers. A model that is right 99% of the time on the training set and 62% of the time on the test set has memorized. A model with 91% and 89% can handle new data. Without a separate test set, you could not see this difference.
Why does data quality matter?
- Missing groups. A face recognition system trained mostly on photos of one age group makes more mistakes on other age groups.
- Old data. A recommendation system trained on shopping habits from four years ago does not know today's customers.
- Wrong labels. If some labels are wrong, the model learns the mistakes.
- Leakage. If a column hides the answer, the model looks great in training and fails in real use. Example: predicting "was the order returned?" while the data has a "return date" column.
Poor data can also lead to unfair results. [AI bias examples](/blog/ai-bias) shows how this happens.
Why do chatbots depend on their training data?
Large language models learn from huge text collections. This has three results. The model does not know events after the data was collected. It is stronger on topics that many people wrote about, and weaker on rare topics and smaller languages. And the mistakes and stereotypes in the texts can pass to the model.
Why is data analysis a basic skill for AI work?
Most of the time in an AI project goes to data: collecting it, cleaning out gaps and errors, checking that it is consistent, and looking at distributions. These are the same skills you use in basic data analysis.
Common mistakes
- Using the test set during training. The result looks better than the real one.
- Building a model without looking at the data. Check gaps, distributions, and strange values first.
- Believing more data is always better. A lot of one-sided data can be worse than a little balanced data.
What to read next
The [AI course](/courses/ai) covers [data, features, and labels](/learn/ai/data-features-labels) and [testing on unseen data](/learn/ai/test-on-unseen-data). For the data side, try the [statistics and data analysis course](/courses/statistics-data-analysis). To see how bad data can treat people unfairly, read [AI bias examples](/blog/ai-bias).
- #training data
- #machine learning
- #test set
- #data quality