Learning algorithm

On this page 7

A learning algorithm is a procedure that takes training data and produces a model whose behavior improves on a defined task, usually by adjusting internal parameters to minimize a loss. In artificial intelligence, it is the component that separates systems that improve from experience from systems whose rules are written entirely by hand.

Among AI fundamentals, the concept is precise: the learning algorithm is not the model itself but the method that searches a space of possible models. Gradient descent training a neural network, the splitting procedure that grows a decision tree and the policy update rule of a reinforcement learning agent are all learning algorithms.

What a learning algorithm consists of

Every learning algorithm combines three ingredients: a hypothesis space of candidate models, an objective function that scores each candidate and an optimization procedure that searches for a good candidate. Changing any one of the three produces a different algorithm with different strengths.

The table describes these building blocks with concrete examples from widely used methods.

ElementRoleExample
Hypothesis spaceDefines which models are possibleAll linear functions, all trees of depth 10
Objective functionMeasures how good a model isMean squared error, cross-entropy, reward
RegularizationPenalizes overly complex modelsL2 weight penalty, tree pruning
Optimization procedureSearches the hypothesis spaceStochastic gradient descent, greedy splitting
Stopping ruleDecides when to end trainingFixed epochs, early stopping on validation loss
Building blocks of a learning algorithm

The assumptions built into these elements form the algorithm’s inductive bias. A convolutional network assumes local spatial patterns matter, while a linear model assumes additive effects. Without some inductive bias, the no free lunch theorem implies that no algorithm can outperform random guessing across all possible problems.

Main families of learning algorithms

Learning algorithms are usually grouped by the type of feedback they receive. The feedback determines what the objective function can measure and therefore what the algorithm can learn.

ParadigmFeedback availableRepresentative algorithmsTypical output
Supervised learningLabeled input-output pairsLogistic regression, gradient boosting, backpropagationClassifier or regressor
Unsupervised learningUnlabeled data onlyk-means, principal component analysisClusters or compressed features
Self-supervised learningLabels derived from the dataMasked or next-token predictionPretrained representations
Reinforcement learningScalar reward from an environmentQ-learning, policy gradient methodsAction policy
Semi-supervised learningFew labels, many unlabeled examplesPseudo-labeling, consistency trainingClassifier
Learning paradigms and representative algorithms

A second distinction separates parametric algorithms, which compress data into a fixed number of parameters, from nonparametric algorithms such as k-nearest neighbors, which keep the training examples and grow in complexity with the dataset. A third separates batch learning, which processes a fixed dataset, from online learning, which updates the model one example at a time.

Learning algorithm, model and inference

Confusion between the learning algorithm and the resulting model is one of the most common errors in AI discussions. The algorithm is the recipe used during training; the model is the trained artifact, defined by its architecture and learned weights; inference is the act of applying the trained model to new inputs.

ConceptWhat it isWhen it runs
Learning algorithmProcedure that fits parametersTraining phase
Model architectureStructure of the hypothesis spaceFixed before training
Model weightsLearned numerical parametersProduced by training
AI inferenceComputing outputs from a trained modelDeployment phase
HyperparametersSettings that control the algorithmChosen before or between runs
How the learning algorithm differs from neighboring concepts

The same architecture can be trained by different algorithms. A neural network can be fitted with stochastic gradient descent, the Adam optimizer or evolutionary search, and each choice can lead to different weights, different training cost and different generalization quality.

How learning algorithms are evaluated and chosen

The central goal is generalization: good performance on data the algorithm has never seen. Practitioners therefore split data into training, validation and test sets, and they judge an algorithm by its error on held-out data, not by its training error.

Theory frames this through the bias-variance trade-off. Simple algorithms underfit because they cannot represent the true pattern, while highly flexible ones overfit by memorizing noise. Computational and statistical learning theory provide sample complexity bounds that relate model capacity, data size and expected error.

The decision table summarizes reasonable starting choices for common situations.

SituationReasonable starting choiceReason
Small tabular datasetGradient-boosted treesStrong accuracy with little tuning
Images, audio or textDeep neural networkLearns features from raw inputs
Need for interpretabilityLinear model or shallow treeTransparent decision logic
Sequential decisions with rewardsReinforcement learningOptimizes long-term outcomes
Few labels, much raw dataSelf-supervised pretrainingUses unlabeled data at scale
Choosing a learning algorithm

Limitations and common mistakes

A learning algorithm can only extract patterns that are present in its data and reachable within its hypothesis space. Biased or unrepresentative data produces biased models, regardless of how sophisticated the algorithm is.

  • Data leakage, where test information reaches training, yields optimistic results that collapse in deployment.
  • Distribution shift between training and production data degrades accuracy silently over time.
  • Optimizing a proxy objective can reward behavior that differs from the real goal.
  • Comparing algorithms without equal tuning effort often favors the method the team knows best.
  • Non-convex optimization offers no guarantee of a global optimum, so results vary with random seeds.

Scale introduces its own constraints. Modern deep learning algorithms can require thousands of accelerator hours, and their behavior depends heavily on learning rate schedules, batch size and initialization. Reproducing a reported result therefore requires documenting every hyperparameter, the data version and the random seed, not only the name of the algorithm.

Finally, a learning algorithm offers no understanding in the human sense. It finds statistical regularities that reduce the objective, and these may include spurious shortcuts, such as a hospital watermark that correlates with a diagnosis. Careful error analysis on realistic examples remains essential before deployment.

Understanding it simply

A learning algorithm is a method for learning from examples. Imagine teaching someone to sort apples by quality. Instead of writing every rule, you show many apples labeled good or bad. The person adjusts a mental rule after each mistake.

A learning algorithm does the same with numbers. It makes a guess, measures the error and adjusts. After many rounds, the result is a trained model that can judge new cases. The algorithm is the teaching method. The model is what the student ends up knowing.

Applied in practice

A regional electricity supplier wants to forecast hourly demand one day ahead. Its analysts have five years of hourly records with temperature, calendar features and holiday flags, about 44,000 labeled examples in total.

They compare three learning algorithms using the same data split: ordinary least squares regression, a random forest and gradient-boosted decision trees. Each is tuned with cross-validation on the first four years, and the final year serves as an untouched test set.

The linear model reaches a mean absolute percentage error of about 6 percent, the random forest about 3.8 percent and gradient boosting about 3.1 percent. The team deploys gradient boosting, schedules monthly retraining to handle seasonal drift and keeps the linear model as an interpretable baseline for auditing unusual forecasts.