Skip to content
Query Feedz
  • News
  • Business
    • Digital Marketing
      • Marketing & Sales
      • SEO
      • Content Marketing
      • AEO and GEO
    • Startups
      • Founder Stories
      • Funding & VC
      • Product & Growth
    • Money
      • Investing
      • Markets & Economy
      • Saving & Budgeting
  • AI & Technology
    • Technology
      • Consumer Tech
      • CRM
      • Cyber Security
      • Software Engineering
      • WordPress
      • Hardware
    • Artificial IntelligenceAI Glossary
      • LLMs
      • Machine Learning
      • AI Fundamentals
      • Generative AI
      • Deep Learning
    • AI Use Cases
      • Automation
      • Content
      • Customer Support
      • Finance
      • Marketing
      • View All
  • Tools & Software
  • Account
    • Submit Guest Post
    • Submit a tool
    • My listing
  • Contact
QueryFeedz
  • News
  • Business
    • Digital Marketing
      • Marketing & Sales
      • SEO
      • Content Marketing
      • AEO and GEO
    • Startups
      • Founder Stories
      • Funding & VC
      • Product & Growth
    • Money
      • Investing
      • Markets & Economy
      • Saving & Budgeting
  • AI & Technology
    • Technology
      • Consumer Tech
      • CRM
      • Cyber Security
      • Software Engineering
      • WordPress
      • Hardware
    • Artificial IntelligenceAI Glossary
      • LLMs
      • Machine Learning
      • AI Fundamentals
      • Generative AI
      • Deep Learning
    • AI Use Cases
      • Automation
      • Content
      • Customer Support
      • Finance
      • Marketing
      • View All
  • Tools & Software
  • Account
    • Submit Guest Post
    • Submit a tool
    • My listing
  • Contact
QueryFeedz
  1. Home /
  2. AI Glossaries /
  3. Machine Learning /
  4. What is a Loss Function?
Machine Learning

What is a Loss Function?

Updated September 26, 2026 Read 3 min

A loss function is a formula that measures how far a machine learning model's predictions are from the correct answers. Training works by adjusting the model to make this number as small as possible.

Contents 11
  1. 01Key takeaways
  2. 02A loss function explained in simple terms
  3. 03Loss vs cost vs objective
  4. 04Common loss functions
  5. 05How a loss function guides training
  6. 06Loss function vs evaluation metric
  7. 07How to choose a loss function
  8. 08Limitations
  9. 09Common Use Cases
  10. 10Frequently Asked Questions
  11. 11Related Terms

A loss function is a mathematical formula that measures how far a machine learning model’s predictions are from the correct answers. It turns “how wrong is the model?” into a single number. Training works by adjusting the model’s parameters, usually with gradient descent, to make that number as small as possible.

Key takeaways

  • The loss function defines what “good” means for a model during training.
  • Mean squared error is standard for regression; cross-entropy is standard for classification.
  • Loss functions are for training; evaluation metrics are for reporting to people. They can differ.
  • Choosing the wrong loss makes the model optimise the wrong goal.

A loss function explained in simple terms

A darts player needs a score to know how well they are doing. A loss function is the model’s scorecard, except lower is better. Each prediction is compared with the true answer, the size of the miss is calculated, and the misses are combined into one number. The model then adjusts itself to reduce that number next time.

Loss vs cost vs objective

  • Loss function: error for a single example.
  • Cost function: average loss across the whole dataset or batch, sometimes plus regularisation.
  • Objective function: the general term for whatever is being optimised, minimised or maximised.

In practice, many people use “loss” and “cost” interchangeably.

Common loss functions

Loss functionTaskWhat it does
Mean squared error (MSE)RegressionAverages squared errors; heavily punishes large mistakes
Mean absolute error (MAE)RegressionAverages absolute errors; less sensitive to outliers
Huber lossRegressionBehaves like MSE for small errors and MAE for large ones
Binary cross-entropy (log loss)Binary classificationPunishes confident wrong probabilities strongly
Categorical cross-entropyMulti-class classificationCompares predicted class probabilities with the true class
Hinge lossClassification (SVMs)Encourages a margin between classes
Focal lossImbalanced classificationFocuses on hard, misclassified examples
Contrastive and triplet lossSimilarity learningPulls similar items together and pushes different ones apart

Large language models are trained with cross-entropy on next-token prediction: the loss measures how much probability the model gave to the actual next word.

How a loss function guides training

  1. The model makes predictions on a batch of training data.
  2. The loss function scores the error.
  3. The gradient of the loss shows how to change each parameter to reduce it.
  4. The optimiser updates the parameters.
  5. Training and validation loss are tracked to spot overfitting.

Loss function vs evaluation metric

The loss must usually be smooth and differentiable so gradient descent can use it. Business metrics often are not. For example, a fraud model may be trained with cross-entropy but judged on recall at a fixed false-alarm rate. The two should be aligned, but they are not always the same thing. If loss falls but the business metric does not improve, the loss may not match the real goal.

How to choose a loss function

  • Match the task: numbers, categories, rankings or similarity.
  • Consider outliers: MSE is sensitive; MAE and Huber are more robust.
  • Consider imbalance: weighted cross-entropy or focal loss help rare classes.
  • Consider error costs: if under-predicting stock is worse than over-predicting, use an asymmetric loss such as quantile loss.
  • Add regularisation terms to discourage overly complex models.

Limitations

A model optimises exactly what the loss measures, nothing more. A poorly chosen loss can produce a model that scores well mathematically but fails the real goal. Loss values are also hard to interpret on their own; compare them over time and against baselines rather than in isolation.

Common Use Cases

01

Regression model training

Use MSE, MAE or Huber loss to train price and demand forecasting models.

02

Classifier training

Use cross-entropy to train spam, fraud and churn classifiers.

03

Imbalanced fraud detection

Use weighted or focal loss so rare fraud cases get more attention.

04

Inventory forecasting

Use quantile loss when under-stocking costs more than over-stocking.

05

Language model training

Use cross-entropy on next-token prediction to train LLMs.

06

Search and recommendations

Use contrastive or ranking losses to learn useful similarity.

Frequently Asked Questions

A formula that measures how far a model's predictions are from the true answers. Training aims to minimise it.

A loss usually refers to one example's error, and a cost to the average across a dataset. Many people use the terms interchangeably.

Cross-entropy, also called log loss, is the standard choice for classification.

Mean squared error is the most common, with MAE and Huber loss used when outliers are a concern.

No. The loss is optimised during training and must usually be differentiable. Metrics measure business-relevant performance and can differ.

Related Terms

  • Gradient Descent
  • Cross-Entropy
  • Mean Squared Error
  • Regression
  • Classification
  • Regularisation

Related AI Terms

What is Hyperparameter Tuning?Hyperparameter tuning is the process of systematically searching for the configuration values that make a model perform best…What is L2 Regularization?L2 regularization adds a penalty equal to the sum of the squared weights, shrinking all weights smoothly towards…What is L1 Regularization?L1 regularization, known as lasso in linear models, adds a penalty equal to the sum of the absolute…What is Cross-Validation in Machine Learning?Cross-validation is a technique that repeatedly splits data into training and validation parts, rotating which part is held…What is Stochastic Gradient Descent (SGD)?Stochastic gradient descent (SGD) updates a model's weights using one example or a small batch at a time…What is the Bias-Variance Tradeoff?The bias-variance tradeoff describes how a model's error splits into bias from overly simple assumptions and variance from…

Contents

  1. 01Key takeaways
  2. 02A loss function explained in simple terms
  3. 03Loss vs cost vs objective
  4. 04Common loss functions
  5. 05How a loss function guides training
  6. 06Loss function vs evaluation metric
  7. 07How to choose a loss function
  8. 08Limitations
  9. 09Common Use Cases
  10. 10Frequently Asked Questions
  11. 11Related Terms

AI Topic

  • Machine Learning

Related Terms

  • What is Hyperparameter Tuning?
  • What is L2 Regularization?
  • What is L1 Regularization?
  • What is Cross-Validation in Machine Learning?
  • What is Stochastic Gradient Descent (SGD)?
  • What is the Bias-Variance Tradeoff?

Quick Navigation

  • Common Use Cases
  • Frequently Asked Questions
  • Related Terms
  • Back to top

Details

Updated
September 26, 2026
Read
3 min
  • Forum
  • Submit a tool
  • Submit Guest Post
  • List Your Startup
  • Privacy Policy
  • Editorial Policy
  • Account
  • Contact
  • AI Productivity
  • AI Video
  • AI Coding
  • AI Chatbots
  • Sales
  • AI Business
  • View All Tools

Subscribe our Newsletter

Get weekly exclusive content - No spam.

Copyright © 2026 -  Query Feedz

Manage Consent
To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.
Functional Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes. The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.
  • Manage options
  • Manage services
  • Manage {vendor_count} vendors
  • Read more about these purposes
View preferences
  • {title}
  • {title}
  • {title}