Introduction to Machine Learning
Foundations and Major Paradigms of Machine Learning
What Machine Learning Means
Machine learning studies methods that allow computers to improve at tasks through experience rather than relying only on instructions explicitly written for every situation. In traditional programming, a person specifies rules directly. In machine learning, a model is trained from data so that it can make predictions or decisions on new inputs.
A widely used formulation describes learning through three components:
Experience (E): The information from which the model learns. This can include collected data, human-labeled examples, data generated by other models, or information gathered through interaction with the world.
Task (T): The activity the model is expected to perform, such as predicting a house price, identifying an object, or generating text.
Performance measure (P): A way to measure how well the model performs the task, such as prediction error, classification accuracy, or success rate.
A program is said to learn when its performance on a task improves as it gains experience. The performance measure matters because learning needs a goal: without a way to distinguish better outcomes from worse ones, there is no clear direction for improvement.
For example, in a game-playing system:
The game is the task.
Gameplay provides experience.
The win rate measures performance.
A central idea is that additional experience should help the model improve. If exposure to more relevant data does not improve performance, then the system may not be learning effectively.
Inputs, Outputs, and Data
Many machine-learning problems can be described using inputs and outputs:
x denotes an input.
y denotes the desired output associated with that input.
A dataset may consist of pairs (x,y). During training, the model uses these examples to learn a relationship between inputs and outputs. During testing or use, it receives a new input x and produces a prediction for its corresponding output y.
In a house-price example:
The input might be a house’s floor area.
The output might be its sale price.
Each house contributes an input-output pair.
The terms features and inputs are often used for the information provided to the model. The terms labels and outputs can refer to the values the model is meant to predict. A label is an output assigned to an input, either by a person or by an automated process.
Realistic problems usually involve more than one input feature. A house price may depend on floor area, lot size, number of floors, condition, and location. These form a higher-dimensional input. Outputs can also be more complex than a single number or category.
Supervised Learning
Supervised learning uses examples in which the desired output is provided alongside each input. The model learns to predict outputs from inputs by comparing its predictions with the supplied labels.
A general supervised-learning dataset has the form:
The specific form of the output determines whether the problem is usually treated as regression or classification.
Regression
Regression predicts a continuous numerical value. The output can take values across a range rather than belonging to a fixed set of categories.
For example, a model can predict house price from floor area. A simple approach is to fit a line through observed examples and use that line to estimate the price for a new house. A quadratic function or another more flexible curve may fit the data better when the relationship is not well described by a straight line.
Regression involves several connected choices:
Model: The mathematical form used to map inputs to predictions, such as a line or quadratic function.
Loss function: A numerical measure of how far predictions are from the observed outputs.
Training algorithm or optimizer: The procedure used to adjust the model so as to reduce its loss.
These ideas apply beyond simple examples. A more realistic price model can take many property characteristics as inputs, making it a multidimensional prediction problem.
Classification
Classification predicts a discrete category, also called a class. Examples include determining whether a property is a house or a townhouse, or identifying the main object in an image.
In a two-class problem, inputs may be represented as points in a feature space, with different symbols marking the classes. A classifier divides the space into regions and assigns a class to each region. The boundary between the regions is called a decision boundary.
Classification also underlies many language-model predictions. When a language model predicts the next token, it selects from a finite vocabulary of possible tokens. The model therefore makes a choice among discrete labels, even though that choice occurs within a much larger text-generation process.
Examples of Supervised-Learning Tasks
Image classification: The input is an image, represented by its pixels; the output is a category, such as “cat” or “flamingo.”
Object localization: The input is an image; the output describes the location of objects. A rectangular bounding box can be represented by four coordinates specifying its two opposite corners.
Machine translation: The input is text in one language, and the output is a translation in another language.
Price prediction: The input consists of property features, and the output is a numerical price.
The input and output need not have the same form. An image can map to a category or set of coordinates, while a text sequence can map to another text sequence.
Image Classification and Large Datasets
Large labeled image collections made it possible to train image classifiers on a scale that had previously been difficult. ImageNet, for example, contains roughly one million labeled images. Training a deep-learning system on such a large collection led to a major improvement in image-recognition performance and helped establish deep learning as a powerful approach in computer vision.
This example illustrates how learning can depend on both:
The amount and quality of experience: A large collection provides many examples.
The model and training method: A suitable architecture and optimization procedure allow the model to make effective use of those examples.
Image classification remains a limited task compared with general-purpose visual understanding. A classifier may identify the main object without being able to answer arbitrary questions about the image.
Unsupervised Learning
Unsupervised learning works with inputs that do not have supplied target outputs. The dataset contains examples, but there is no explicit label stating what each example should be predicted to represent.
The goal is to find patterns or structure within the data. This goal is less precisely defined than supervised prediction because the notion of “interesting structure” depends partly on the method and on what relationships the method is designed to uncover.
Clustering
Clustering groups examples that are considered similar. In a two-dimensional dataset, groups may be visible as concentrations of nearby points. In higher-dimensional data, similarity is less directly visible, so an algorithm must use a defined measure of similarity or objective.
Different clustering methods can produce different groupings because they may use different definitions of similarity. Thus, clusters should be understood as structure revealed by a particular method, not necessarily as a single uniquely correct partition of the data.
Clustering can be applied to:
Individuals with similar patterns of gene expression.
Documents that use similar words.
Other examples that can be represented in a form suitable for comparing similarity.
Finding Structure in Gene-Expression Data
A gene-expression dataset can be arranged as a table whose columns represent individuals and whose entries record gene-related measurements. Reordering the individuals and genes may reveal groups with similar patterns.
These patterns can help researchers identify groups of individuals with related expression profiles and investigate possible connections between genes, diseases, or symptoms. Clustering can organize the data, but the resulting groups alone do not establish that a particular gene causes a particular disease.
Document Clustering and Latent Semantic Analysis
Documents can be represented through a word-document matrix. Each entry records how often a particular word appears in a particular document. A darker or larger value can represent a higher word count.
The original matrix may not show obvious relationships. Reordering its rows and columns can reveal groups of documents with similar word-use patterns and groups of words that frequently occur together. For example, documents that often contain terms related to spaceflight may form one group, while documents containing terms about pollution and the environment may form another.
Latent Semantic Analysis (LSA) is a technique associated with uncovering latent relationships in word-document data. It can help identify patterns among both words and documents, even when those patterns are not immediately visible in the original representation.
Word Embeddings
A word embedding represents a word as a numerical vector in a high-dimensional space. Words with related meanings or uses can have vectors that are close to one another.
Embeddings can also encode relationships as approximate directions. For example, a direction in the vector space may correspond to a relationship between a country and its capital. Moving from a country vector along such a direction may lead near the vector for its capital. These relationships are learned from patterns in text; they are useful regularities, not guaranteed symbolic rules.
Early embedding methods could be trained on large collections of unlabeled text, such as Wikipedia. This illustrates how a model can learn useful representations without being given a separate human-provided label for every word.
Image Generation
Some generative methods learn from collections of images without needing a separate class label for each image. A diffusion model is one approach to image generation: it learns to produce realistic images, often by reversing a process that gradually adds noise.
Generation and classification are different goals. A classifier assigns an image to a category, while a generative model produces new image content that resembles patterns in its training data.
Deep Learning
Deep learning uses neural networks with many layers of computation to represent complex relationships between inputs and outputs. A network can be pictured as nodes connected by weighted edges. In this analogy, nodes resemble neurons and connections resemble synapses, although an artificial neural network is a mathematical model rather than a complete simulation of a human brain.
A network’s adjustable numerical values are its parameters. Modern networks may have very large numbers of parameters. Training changes these parameters so that the network’s predictions better match the training objective.
A basic deep-learning workflow involves:
Choosing a network architecture.
Defining a loss function that measures the quality of its predictions.
Computing how the loss changes with respect to the network’s parameters.
Updating the parameters using an optimization procedure.
Backpropagation is the method used to efficiently compute gradients through a neural network. The gradients indicate how parameter changes affect the loss, allowing an optimizer to adjust the network. This makes it possible to train complex models containing many connected computations.
Deep learning supports tasks such as image classification, language modeling, and other applications. The core training ideas include model design, loss functions, gradient computation, and optimization.
Large Language Models
A large language model (LLM) is trained on massive collections of text and is designed to perform many language tasks rather than only one narrowly defined task. In contrast with a system built for a single purpose, a general-purpose language model can respond to questions, follow instructions, and produce different kinds of text.
A central language-modeling task is predicting the next token. The model assigns probabilities to possible next tokens and then selects or samples one. Because the vocabulary contains many discrete possibilities, this prediction can be understood as a classification problem over the available tokens.
A model’s response can depend on how an instruction is phrased. Training methods can make models more responsive to instructions, so that they are more likely to produce outputs that follow a user’s request. The model’s underlying text-generation abilities and its ability to follow instructions are related but distinct aspects of its behavior.
A useful distinction is:
Using a model: Giving it prompts or instructions to accomplish a task.
Training a model: Changing its parameters or behavior through data and learning procedures.
A foundational study of machine learning focuses primarily on how models are trained and why the algorithms work, rather than only on how to use particular software tools.
Reinforcement Learning
Reinforcement learning (RL) studies how an agent can make decisions over time. Rather than receiving the correct output for every input, the agent takes actions, observes what happens, and receives feedback such as rewards.
Sequential Decisions
In reinforcement learning, an action can affect not only the immediate result but also later possibilities. This makes the task sequential.
For example, a robot learning to walk must repeatedly decide how to move its limbs. A poor action may cause it to fall, changing what it can do next. A game-playing agent faces the same general structure: each move affects the state of the game and the decisions available later.
This differs from a standard supervised-learning setup in which a fixed collection of input-output examples is typically provided in advance.
Trial, Feedback, and New Data
Reinforcement learning often follows a cycle:
The agent tries a strategy or takes actions.
It receives feedback from the resulting outcomes.
The actions and observations form new experience.
The agent is trained using this experience.
It tries an improved strategy and collects further data.
Because the agent helps generate the experience from which it learns, reinforcement learning can be interactive. A failed attempt can still provide useful information: a robot’s fall, for example, is part of the recorded trajectory of actions and observations.
This cycle can produce a bootstrapping effect. An improved system may generate better examples, which can then support further improvement. In automated theorem proving, a model might generate candidate proofs, a verifier might identify valid ones, and the valid proofs might be used as additional training data. The model can then attempt to generate more correct proofs in a later round.
Rewards for Language-Model Outputs
Reinforcement learning can also be used to improve language-model responses. A user prompt is supplied to the model, which generates text. Another component—such as a human, a reward model, or another evaluation system—assigns a reward indicating how desirable the text is. That reward guides updates intended to make future responses better.
One reason reinforcement-learning methods are useful here is that text generation involves sampling discrete tokens. The sampling step is stochastic and is not ordinarily a differentiable operation through which standard gradients can simply be propagated. Reinforcement-learning methods provide ways to optimize behavior when outcomes depend on such sampled actions.
Policy Gradients
A policy describes how an agent chooses actions. Policy-gradient methods adjust a policy so that actions associated with higher rewards become more likely.
In language generation, each token choice can be viewed as an action. Generation is sequential because earlier tokens affect the context used to choose later tokens. A response can therefore be treated as a sequence of decisions, with an evaluation of the complete response guiding learning.
Terms such as reward with human feedback and reward with a verifier describe different ways of evaluating generated outputs. The broad principle is to use feedback about output quality to encourage more desirable future behavior.
Connections Among the Learning Paradigms
Supervised learning, unsupervised learning, and reinforcement learning are useful broad categories, but they are not mutually exclusive. Modern systems may combine methods from more than one category.
Supervised learning uses input-output examples to learn a specified prediction task.
Unsupervised learning looks for patterns in inputs without supplied target outputs.
Reinforcement learning uses actions and feedback in sequential or interactive settings.
The categories can describe either tasks or methods, depending on context. For example, supervised fine-tuning is a supervised-learning method that can contribute to a broader general-purpose model. A system’s overall goal may be broad even when particular stages of its training use specialized learning paradigms.
Machine learning is also a rapidly changing field, so taxonomies are practical ways to organize ideas rather than permanent, universally agreed classifications.
Machine-Learning Systems and Social Effects
The performance of an AI system depends not only on its learning algorithm but also on the software and hardware used to run it. Machine-learning systems examines how algorithms interact with computing systems, including how to make training and inference more efficient.
Efficiency can have both financial and practical consequences. If a method runs faster, it can reduce computing costs or allow more experiments in the same amount of time. In a field where training and deployment can require substantial resources, even moderate efficiency improvements may be significant.
AI also has social impacts that extend beyond technical performance. As systems take on tasks previously performed by people, their effects on work and employment become important considerations. Understanding AI therefore involves both the mechanisms that make systems effective and the consequences of deploying them.
A complete understanding of machine learning connects data, objectives, models, optimization, computation, and the effects of using trained systems.

Ask anything
We've read this whole study set, so questions about it get the best answers.