Ultralytics YOLO27:
Back to Ultralytics Glossary

Linear Regression

Explore linear regression fundamentals and its role in AI. Learn how Ultralytics YOLO26 uses regression for precise object detection and bounding box coordinates.

Linear Regression is a fundamental statistical method and a foundational algorithm in supervised learning used to model the relationship between a dependent variable (target) and one or more independent variables (features). Unlike classification algorithms that predict discrete categories, linear regression predicts a continuous output, making it essential for tasks where the goal is to forecast specific numerical values. Its simplicity and interpretability serve as a gateway to understanding more complex machine learning (ML) concepts, as it introduces the core mechanics of how models learn from data by minimizing error.

Core Mechanics and Training#

The primary objective of this technique is to find the "line of best fit"—or a hyperplane in higher dimensions—that best describes the data pattern. To achieve this, the algorithm calculates a weighted sum of the input features plus a bias term. During the training process, the model iteratively adjusts these internal parameters, known as weights and biases, to reduce the discrepancy between its predictions and the actual ground truth.

This discrepancy is quantified using a loss function, with the most common choice being Mean Squared Error (MSE). To effectively minimize the loss, an optimization algorithm such as gradient descent is employed to update the weights. If the model aligns too closely with the noise in the training data, it risks overfitting, whereas a model that is too simple to capture the underlying trend suffers from underfitting.

Real-World Applications in AI#

While often associated with simple predictive modeling in data analytics, linear regression principles are deeply embedded in advanced deep learning (DL) architectures.

  • Financial Forecasting: Analysts use regression to predict housing prices, stock values, or sales revenue based on historical data points like square footage, location, or previous market trends.
  • Computer Vision and Object Detection: Modern object detectors, such as the YOLO26 family of models, utilize regression in their detection heads. Specifically, the model performs "bounding box regression" to predict the precise continuous coordinates (center x, center y, width, height) of an object within an image.

Linear Regression vs. Logistic Regression#

It is important to distinguish this term from Logistic Regression. Although both are linear models, their outputs differ significantly. Linear regression predicts a continuous numeric value (e.g., the price of a car). In contrast, logistic regression is used for classification tasks, predicting the probability that an input belongs to a specific category (e.g., whether an email is "spam" or "not spam") by passing the linear output through an activation function like the sigmoid function.

Example: Regression in Object Detection#

In the context of computer vision, when a model like Ultralytics YOLO26 detects an object, the bounding box coordinates are the result of a regression task. The model predicts continuous values to locate the object precisely.

from ultralytics import YOLO

# Load the YOLO26 model (nano version)
model = YOLO("yolo26n.pt")

# Run inference on an image
# The model uses regression to determine the exact box placement
results = model("https://ultralytics.com/images/bus.jpg")

# Display the continuous regression outputs (x, y, width, height)
for box in results[0].boxes:
    print(f"Box Regression Output (xywh): {box.xywh.numpy()}")

Users looking to train custom models that leverage these regression capabilities for specialized datasets can utilize the Ultralytics Platform for streamlined annotation and cloud training. Understanding these basic regression principles provides a solid foundation for mastering complex tasks in artificial intelligence (AI) and computer vision.

Explore solutions

Computer vision for aerial imagery

Computer vision for aerial imagery

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

Computer vision in aerospace

Bring vision AI to aerial monitoring with Ultralytics YOLO models. Power drones, aerospace workflows, environmental conservation & geospatial industries with computer vision solutions.
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
Computer vision for aerial imagery

Computer vision for aerial imagery

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

Computer vision in aerospace

Bring vision AI to aerial monitoring with Ultralytics YOLO models. Power drones, aerospace workflows, environmental conservation & geospatial industries with computer vision solutions.
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
Computer vision for aerial imagery

Computer vision for aerial imagery

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

Computer vision in aerospace

Bring vision AI to aerial monitoring with Ultralytics YOLO models. Power drones, aerospace workflows, environmental conservation & geospatial industries with computer vision solutions.
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