Ultralytics YOLO27: Join the waitlist.
License YOLO
Back to Ultralytics Glossary

Underfitting

Underfitting is when a model is too simple or undertrained to capture the patterns in its data, so it errs on training and new data alike. Signs and fixes.

Underfitting occurs when a machine learning (ML) model fails to capture the patterns in its training data, so it makes large errors on the examples it learned from as well as on new ones. Fitting a straight line through points that follow a curve, as plain linear regression does, is the classic picture: no choice of slope and intercept can follow the bend. An underfit model has high bias, meaning its assumptions are too restrictive for the true relationship between inputs and outputs, and its accuracy is low on the training set as well as on test data.

Signs of Underfitting#

The clearest signal is a training loss that stays high. When the loss function plateaus well above an acceptable level and the validation data loss sits close to it, the model is not learning enough, and the small gap between the two shows that memorization is not the problem. Learning curves that plot error against training set size show a second sign: both curves flatten at a high error, so adding more data of the same kind barely helps. In object detection, a model that scores a low mean average precision (mAP) on the very images it was trained on is underfitting, one of the checks in the Ultralytics model testing guide. Comparing both losses separates underfitting from overfitting:

Common Causes#

  • Too little capacity: The model family cannot represent the pattern, such as a linear model on curved data or a very small network on a complex vision task.
  • Too few epochs: Stopping training early, or using a learning rate too small to make progress in the time available, halts the optimizer before it converges.
  • Too much regularization: Strong weight decay, high dropout rates, or very aggressive augmentation constrain the model so tightly that it cannot fit the signal.
  • Uninformative features: Missing variables, or images downscaled until small objects vanish, remove the information the model needs.
  • Vanishing gradients and other optimization failures: Early layers of a deep network stop learning even when the model has enough capacity.

Underfitting in Code#

The following example fits noisy samples of a sine curve with a straight line and with a cubic polynomial using scikit-learn, then reports the mean squared error (MSE) on training and test points:

import numpy as np
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_squared_error
from sklearn.model_selection import train_test_split
from sklearn.pipeline import make_pipeline
from sklearn.preprocessing import PolynomialFeatures

# Noisy samples of a curved function
rng = np.random.default_rng(0)
x = rng.uniform(-3, 3, size=(200, 1))
y = np.sin(x).ravel() + rng.normal(0, 0.1, size=200)
x_train, x_test, y_train, y_test = train_test_split(x, y, random_state=0)

# A straight line underfits; a cubic polynomial has enough capacity for the curve
for degree in (1, 3):
    model = make_pipeline(PolynomialFeatures(degree), LinearRegression()).fit(x_train, y_train)
    train_mse = mean_squared_error(y_train, model.predict(x_train))
    test_mse = mean_squared_error(y_test, model.predict(x_test))
    print(f"degree {degree}: train MSE {train_mse:.3f}, test MSE {test_mse:.3f}")

The straight line scores a training MSE of 0.193 and a test MSE of 0.188, high and nearly equal, which is the signature of underfitting. The cubic drops both to 0.013 and 0.017, close to the 0.010 floor set by the noise added to the data.

Fixing Underfitting#

Fixes target the cause: a larger or more expressive model, longer training with a suitable learning rate, weaker regularization or data augmentation, and richer inputs such as higher image resolution. YOLO26 comes in n, s, m, l, and x sizes that scale the depth and width of one architecture, so moving from yolo26n.pt to a larger size is the usual first step when both the training and validation losses in a run's results.csv stay high. Small objects are a common case in computer vision: a detector that sees drone footage at a low input size misses small objects that a larger input size would preserve.

Underfitting vs. Overfitting#

Underfitting and overfitting are the two failure modes of the bias-variance tradeoff. An underfit model has high bias and errs similarly on training and new data, while an overfit model has high variance, fitting its training data closely, noise included, and generalizing poorly. The classical picture is a U-shaped test error curve with underfitting on the left and overfitting on the right. Large neural networks complicate it through double descent, where test error can fall again once a model is large enough to fit its training data exactly, a pattern observed across model size and training epochs.

Explore solutions

Computer vision in sports

Computer vision in sports

Discover how Ultralytics YOLO powers sports vision with player and ball tracking, performance analytics, coaching insights, and athlete rehabilitation.
Learn more
Computer vision for aerial imagery

Computer vision for aerial imagery

Turn drone and aerial imagery into real-time insights for agriculture, aquaculture, conservation, and geospatial analysis with Ultralytics YOLO.
Learn more
Computer vision in aerospace

Computer vision in aerospace

Apply computer vision in aerospace with Ultralytics YOLO for aircraft inspection, runway FOD detection, airport ground operations, and composite defect detection.
Learn more
Computer vision in security

Computer vision in security

Protect every site with Ultralytics YOLO models. Vision AI powers perimeter monitoring, threat detection, license-plate recognition, and workplace safety.
Learn more
Computer vision in robotics

Computer vision in robotics

Power smarter machines with Ultralytics YOLO models. Vision AI in robotics drives autonomous navigation, perception, object tracking, and real-time control.
Learn more
Computer vision in logistics

Computer vision in logistics

Streamline logistics with Ultralytics YOLO models. Vision AI enables package inspection, sorting, vehicle tracking, and real-time warehouse safety monitoring.
Learn more
Computer vision in retail

Computer vision in retail

Reimagine retail with Ultralytics YOLO models. Vision AI powers inventory tracking, shelf monitoring, queue management, and smarter customer insights.
Learn more
Computer vision in healthcare

Computer vision in healthcare

Build healthcare solutions with Ultralytics YOLO models. Vision AI in healthcare powers faster medical imaging, smarter diagnostics, and patient monitoring.
Learn more
Computer vision in manufacturing

Computer vision in manufacturing

Optimize manufacturing with Ultralytics YOLO models. Vision AI drives quality control, defect detection, PPE compliance, and assembly line automation.
Learn more
Computer vision in automotive

Computer vision in automotive

Apply computer vision in automotive with Ultralytics YOLO models. Vision AI elevates road safety, driver assistance, and vehicle automation for smarter roads.
Learn more
Computer vision in agriculture

Computer vision in agriculture

Bring vision AI to smart agriculture with Ultralytics YOLO models. Power crop monitoring, livestock tracking, and precision farming for higher, smarter yields.
Learn more

Let's build the future of AI together!

Begin your journey with the future of machine learning