Overview

2 Types of machine learning

Machine learning teaches computers to make decisions from experience by learning patterns in data. This chapter introduces the main ways models learn, organized by the kind of data and feedback available. It clarifies the building blocks—data points, features, and labels—and distinguishes labeled data (with a target to predict) from unlabeled data (without explicit targets). With that foundation, it presents the three major families of machine learning: supervised learning for predicting known labels, unsupervised learning for discovering structure without labels, and reinforcement learning for training an agent to act through rewards and penalties.

Supervised learning operates on labeled datasets to predict outcomes for new examples. It splits into regression, which predicts numerical values (such as house prices or recovery times), and classification, which predicts categorical states (such as spam vs. not spam, sick vs. healthy, or dog vs. cat). The chapter highlights common applications across text, images, recommendations, and forecasting, and notes that labels can be numerical or categorical, guiding the choice between regression and classification. It also previews widely used algorithms—linear models, decision trees, neural networks, support vector machines, and ensemble methods—while emphasizing that the book focuses primarily on supervised approaches.

Unsupervised learning extracts insight from unlabeled data by uncovering structure and simplifying representation. Clustering groups similar items (useful for market segmentation, organizing emails, or image partitioning), while dimensionality reduction condenses many features into a smaller set that preserves most information. Techniques like matrix factorization and singular value decomposition can reduce both rows and columns, enabling recommendations and data compression. The chapter also surveys generative learning, which creates new, realistic samples akin to the training data (for example with GANs or VAEs), and introduces reinforcement learning, where an agent learns to achieve goals through reward-driven exploration—powering advances in game-playing, robotics, and self-driving systems.

Labeled data is data that comes with a tag, or label. That label can be a type or a number. Unlabeled data is data that comes with no tag. The dataset on the left is labeled, and the label is the type of pet (dog/cat). The dataset in the middle is also labeled, and the label is the weight of the pet (in pounds). The dataset on the right is unlabeled.
A supervised learning model predicts the label of a new data point. In this case, the data point corresponds to a dog, and the supervised learning algorithm is trained to predict that this data point does, indeed, correspond to a dog.
A supervised learning model follows the remember-formulate-predict framework from chapter 1. First, it remembers the dataset. Then, it formulates rules for what would constitute a dog and a cat. Finally, it predicts whether a new data point is a dog or a cat.
An unsupervised learning algorithm can still extract information from data. For example, it can group similar elements together.
A plot of the email dataset. The horizontal axis corresponds to the size of the email and the vertical axis to the number of recipients. We can see three well-defined clusters in this dataset.
We can cluster the emails into three categories based on size and number of recipients.
Dimensionality reduction algorithms help us simplify our data. On the left, we have a housing dataset with many features. We can use dimensionality reduction to reduce the number of features in the dataset without losing much information and obtain the dataset on the right.
How to imagine higher dimensional spaces: One dimension is like a street, in which each house only has one number. Two dimensions is like a flat city, in which each address has two numbers, a street and an avenue. Three dimensions is like a city with buildings, in which each address has three numbers: a street, an avenue, and a floor. Four dimensions is like an imaginary place in which each address has four numbers. We can imagine higher dimensions as another imaginary city in which addresses have as many coordinates as we need.
Clustering can be used to simplify our data by reducing the number of rows in our dataset by grouping several rows into one.
Dimensionality reduction can be used to simplify our data by reducing the number of columns in our dataset.
A grid world in which our agent is a robot. The goal of the robot is to find the treasure chest, while avoiding the dragon. The mountain represents a place through which the robot can’t pass.
Here is a path that the robot could take to find the treasure chest.

FAQ

What are the three main types of machine learning, and how do they differ?Supervised learning uses labeled data to learn a mapping from features to a target (label). Unsupervised learning works with unlabeled data to discover structure such as groups or lower-dimensional representations. Reinforcement learning trains an agent to act in an environment by maximizing rewards through trial and error.
What is the difference between labeled and unlabeled data?Labeled data includes a special column (the label or target) you want to predict, such as “price” or “spam/ham.” Unlabeled data lacks that target column; you still have features, but no explicit answer to learn from. Whether a column is treated as a label depends on your problem definition.
What do “data,” “features,” “labels,” and “predictions” mean?Data is the information you analyze (often a table). Features are the descriptive columns (inputs). A label (or target) is the specific column you want to predict in supervised learning. A prediction is the model’s guess for the label of a new data point.
What is supervised learning and how does it work at a high level?Supervised learning fits a model to labeled examples and then predicts labels for new inputs. Conceptually, it follows remember–formulate–predict: remember past data, formulate rules (a model), and predict the label for unseen cases.
What is the difference between regression and classification, and how do I choose?Regression predicts numbers (continuous values) such as price, weight, or time watched. Classification predicts categories (discrete states) such as spam/ham or cat/dog. Choose regression when the answer is a real-valued quantity; choose classification when the answer is one of a fixed set of classes.
What are common applications of supervised learning?- Regression: housing price estimation; stock price forecasting; expected customer spend; expected recovery time; expected watch time. - Classification: spam detection; sentiment analysis; image recognition; click-through prediction; fraud detection; friend or content recommendations.
What can unsupervised learning do without labels, and when is it useful?Unsupervised methods uncover structure: grouping similar items (clustering), simplifying data while keeping most information (dimensionality reduction), or synthesizing new, realistic data (generative models). They’re often used to explore data, segment users or items, and as preprocessing to improve supervised models.
What is clustering, and what are popular clustering methods and use cases?Clustering groups data points by similarity to form meaningful clusters. Common methods include K-means, hierarchical clustering, DBSCAN, and Gaussian mixture models. Use cases: market segmentation, organizing documents or emails, grouping images by similarity, medical image segmentation, and recommendation pipelines.
What is dimensionality reduction, and what does “dimension” mean here?Dimension refers to the number of features (columns). Dimensionality reduction combines or transforms features to represent the data with fewer columns while preserving most information (e.g., collapsing multiple “size” variables into one). Benefits include simpler models, faster computation, and easier visualization. Related techniques like matrix factorization and singular value decomposition can reduce both rows and columns, powering applications such as recommendations and image compression.
What is generative machine learning?Generative models learn the distribution of a dataset and can produce new, realistic samples that resemble the originals (images, audio, text, etc.). Notable approaches include GANs, variational autoencoders, and restricted Boltzmann machines. They enable tasks like synthetic image creation, style transfer, music composition, and data augmentation.
What is reinforcement learning, and where is it used?Reinforcement learning trains an agent to take actions in an environment to maximize cumulative reward. The agent learns from rewards and penalties—without labeled examples—by exploring and improving its policy over time. Applications include game-playing (Go, chess, Atari), robotics (manipulation, navigation), and self-driving tasks (path planning and decision-making).

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Grokking Machine Learning, Second Edition ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Grokking Machine Learning, Second Edition ebook for free