Key takeaways
- Overfitting is memorising the training data instead of learning the pattern.
- Underfitting is failing to learn the pattern at all — too simple a model.
- The goal is the balance between them: a model that generalises.
- You spot them by comparing performance on seen vs unseen data.
- Both are fixable once you know what you're looking at.
Two of the most important concepts in machine learning are overfitting and underfitting, and understanding them explains why models succeed or fail. They sound technical, but the ideas behind them are intuitive and even a little funny once you see them clearly. Get these two concepts, and a great deal of machine learning suddenly makes sense — including why a model that looks brilliant in testing can be useless in the real world. This guide explains both with simple analogies and shows you how to spot and fix each.
The two ways a model can fail
When you train a machine-learning model, you want it to learn the underlying pattern in your data so it can make good predictions on new, unseen data. That last part — new, unseen data — is the whole point. A model that only works on data it has already seen is useless, because the reason we build models is to handle the future, not to describe the past. Overfitting and underfitting are the two ways this goal goes wrong: one where the model learns too much of the wrong thing, and one where it learns too little. Understanding both is understanding the central challenge of machine learning.
The student analogy
Picture two students preparing for an exam. The first memorises the exact answers to last year's past paper without understanding the subject. On that specific paper they score perfectly, but when the real exam asks slightly different questions, they fail, because they memorised rather than learned. That is overfitting. The second student barely studies and grasps only the vaguest sense of the subject. They do poorly on the past paper and the real exam alike, because they never learned enough. That is underfitting. The ideal student actually understands the subject, so they handle both the past paper and new questions well. That is the balance we want in a model.
What overfitting is
Overfitting happens when a model learns the training data too well — including its noise, quirks and random details that are not part of the real pattern. Like the memorising student, it performs beautifully on data it has seen and poorly on new data. This usually happens when a model is too complex for the amount of data, giving it enough flexibility to essentially memorise the training examples rather than generalise from them. Overfitting is dangerous precisely because it looks like success at first: your model scores wonderfully in training, and only when it meets real, unseen data does its failure become clear. Recognising it early saves you from deploying a model that will disappoint.
What underfitting is
Underfitting is the opposite: the model is too simple to capture the real pattern in the data, so it performs poorly even on the training data, let alone new data. Like the student who barely studied, it never learned enough to be useful. This happens when a model lacks the flexibility to represent the underlying relationship, or when it has not been trained enough. Underfitting is at least honest — it looks bad from the start rather than hiding until deployment — but it is equally useless. A model that cannot even fit the data it was trained on will not help you predict anything.
The balance you want
Between these two failures lies the goal: a model that has learned the genuine underlying pattern well enough to generalise to new data, without memorising noise. This is often called a model that generalises well, and achieving it is much of the art of machine learning. You want enough complexity to capture the real pattern, but not so much that the model starts memorising quirks. Finding this sweet spot for a given problem and dataset is a central skill, and it is why machine learning is as much craft as science. The whole practice, in a sense, is a search for this balance.
How to spot each problem
The key tool for spotting both is comparing your model's performance on data it was trained on versus data it has not seen — which is exactly why you split your data. If your model performs well on training data but noticeably worse on unseen test data, that gap signals overfitting: it learned the training set too specifically. If your model performs poorly on both training and test data, that signals underfitting: it never learned the pattern well enough. This simple comparison — training performance versus test performance — is how practitioners diagnose which problem they have, and it is the foundation of knowing what to fix.
Fixing overfitting
Once you have diagnosed overfitting, several approaches help. You can use more training data, giving the model more examples so it must learn the general pattern rather than memorising a few. You can simplify the model so it has less capacity to memorise noise. You can use techniques specifically designed to discourage over-complexity and keep the model general. And you can stop training before the model starts memorising. You do not need the technical details as a beginner; the important idea is that overfitting is fixable by reducing the model's ability to memorise and encouraging it to generalise. Diagnosis points you to the remedy.
Fixing underfitting
Underfitting is addressed in largely opposite ways. You can use a more capable model with enough flexibility to capture the pattern. You can give the model better or more informative features to learn from, so the real relationship is easier to find. You can train it longer or more thoroughly. And you can ensure your data actually contains the signal you are hoping to learn. Again, the details matter less than the concept: underfitting means the model needs more capacity or better inputs to learn the pattern. Once you recognise it, the direction of the fix is clear.
The trade-off between them
Overfitting and underfitting sit at two ends of a trade-off, and pushing away from one moves you towards the other. Make a model more complex to cure underfitting, and you risk overfitting; simplify it to cure overfitting, and you risk underfitting. This is why machine learning involves careful tuning and judgement rather than a single correct setting. The aim is to land in the balanced middle for your particular data and problem, using the training-versus-test comparison to guide you. Accepting that this is a balance to be found, not a formula to be applied, is itself an important step in becoming a capable practitioner.
The bottom line
Overfitting and underfitting are the two ways machine-learning models fail: overfitting memorises the training data and flops on new data, while underfitting never learns the pattern at all. The goal between them is a model that generalises. You diagnose which you have by comparing performance on seen versus unseen data, and you fix each by adjusting the model's complexity and inputs in opposite directions. Understand this balance and how to navigate it, and you understand one of the most fundamental ideas in all of machine learning.
Why this matters beyond the exam room
It is easy to treat overfitting and underfitting as academic concepts, but they have very real consequences the moment a model meets the world. Imagine a bank deploys a loan-repayment model that overfitted its training data: in testing it looked superb, but on new applicants it makes poor, unreliable predictions, leading to bad lending decisions and real financial loss. Or picture a health screening tool that underfitted: it never learned the pattern well enough, so it misses cases it should catch. In both cases the failure is not abstract — it costs money, trust, or even wellbeing. Understanding these concepts is therefore not just theory; it is what stands between a model that helps and one that quietly harms.
This is also why the discipline of honest evaluation, covered in related guides, matters so much. The only reason you can catch overfitting before it does damage is that you tested your model on data it had never seen and noticed the gap between training and test performance. A practitioner who skips that step, dazzled by great training results, ships overfitted models without knowing it. So these ideas connect directly to responsible, trustworthy machine learning: you build models that genuinely work in the real world by respecting the balance between overfitting and underfitting, and by always measuring performance honestly on unseen data before you rely on anything.
Frequently asked questions
What is overfitting in simple terms?
What is underfitting?
How do I know if my model is overfitting or underfitting?
Why is overfitting dangerous?
How do I fix overfitting?
How do I fix underfitting?
What is the trade-off between them?
Where can I learn these machine learning concepts properly?
Do overfitting and underfitting matter in real applications?
Is some overfitting or underfitting always present?
Does more data help with overfitting?
Your AI journey can start in Kasoa — or anywhere in Ghana
Turn what you have learned into real, job-ready skills. Learn on campus in Opeikuma, Kasoa, or live online, build a portfolio of real projects, and earn a verifiable certificate with career support until you land the role.