Table of Contents


Last Updated: 2/6/2023

Machine Learning

What is Machine Learning?

Machine Learning, or ML for short, is a subfield of Artificial Intelligence that allows computer systems to learn and improve from experience without being explicitly programmed. The idea behind machine learning is to enable computers to make decisions or predictions based on data without the need for explicit instructions on what to do. Think of it as a student learning from past exams to perform better on the next one. Just like a student uses past exams to identify patterns and make predictions, machines use data to identify patterns and make predictions.

Machine Learning is one if not the most important sub-field of artificial intelligence since it allows any intelligent system to learn, draw conclusions based on that learning, and adapt to changes. ML is closely related to data, algorithms, predictions, and, more importantly, a process.

Aurélien Géron has one of the most precise and concrete definitions:

"Machine Learning is the science (and art) of programming computers so they can learn from data." — Hands On Machine Learning with Scikit-Learn, Keras and TensorFlow - Aurélien Géron.

With a more mathematical approach, Peter Norvig defines ML as a process through which we search for a prediction function f that explains the relationship between the outputs we want to obtain and the input data we receive. This prediction function would allow the intelligent system to make predictions on data it has never seen before.

"Machine learning can also be defined as the process of solving a practical problem by 1) gathering a dataset, and 2) algorithmically building a statistical model based on that dataset. That statistical model is assumed to be used somehow to solve the practical problem." — The hundred Page Machine Learning, - Peter Norvig.

In his "Computing Machinery and Intelligence" paper, Alan Turing explores the idea that computers could go beyond just executing what the programmer tells them. He proposes that computers could think for themselves how to solve a given task.

Machine Learning is an extensive collection of mathematical and statistical algorithms used to find patterns within data, learn from them and make predictions on new data. It is possible to carry out the entire process in various ways; we will explore them here.

Traditional Programming vs. Machine Learning

When you learn how to solve problems using algorithms, you receive a set of input data and the expected output. It's your job to write the specific instructions to turn those inputs into the desired output. The solution is written as steps in a syntax that any computer can understand, called programming languages. The computer's job, in this case, is to execute each instruction as a recipe. Since the first Machine Learning algorithms appeared, this process has been called traditional programming or traditional approach.

Traditional-Programming

The machine learning approach takes the same inputs and outputs we talked about before and hands them to a machine learning algorithm to find the instructions that convert these inputs into the expected outputs.

Machine-Learning

In traditional programming, the programmer provides the rules for the computer to follow. In machine learning, the computer is given data and uses algorithms to learn patterns and make decisions based on those patterns. The outcome in machine learning is determined by the data and the algorithms, not by the programmer.

How does Machine Learning work?

Machine learning is a way for computers to learn and make decisions based on data, without being explicitly programmed. Imagine you want to teach a computer to recognize different types of fruits. You give the computer many pictures of fruits along with their labels (e.g. apple, banana, orange). The computer then uses this information to learn the characteristics of each fruit and build a model. This model can then identify new fruits based on their characteristics. Just like a child learns from their experiences, the computer learns from the data it was trained on. Over time, it can continue to improve its understanding of the fruits by learning from more and more data. This is how machine learning algorithms can become more accurate over time. Machine Learning also makes predictions. For example, a machine learning algorithm can look at data about a person's income, education, and age and use this information to predict their likelihood of getting a loan. We can think of machine learning as a teacher that helps the computer learn from data and make predictions or decisions on its own.

Learning Types

A system can learn in 4 different ways, depending on the data it has available to learn and the process it follows to convert the inputs into outputs.

Supervised Learning

"In supervised learning, the training set you feed to the algorithm includes the desired solutions, called labels". Hands on Machine Learning with Scikit-Learn, Keras and TensorFlow - Aurélien Géron

Supervised learning is a type of machine learning in which the computer is given a set of labeled data and uses that data to make predictions about new, unseen data.

Think of it like a teacher giving a student practice problems to solve. The teacher provides the student with the answers (the labeled data), and the student uses that information to solve new problems (the unseen data). In the same way, the computer uses the labeled data to make predictions about the new data.

Supervised

For example, a supervised learning algorithm might be trained on a dataset of pictures of animals and the labels that tell the algorithm what type of animal is in each picture. Once the algorithm has been trained, it can then be used to make predictions about new pictures of animals that it has never seen before.

"The goal of a supervised learning algorithm is to use the dataset to produce a model that takes a feature vector x as input and outputs information that allows deducing the label for this feature vector". — The Hundred Page Machine Learning - Perter Norvig.

Some of the most popular problems solved with Supervised Learning are Regression, Classification, Detection, Forecasting, Ensembling, Recommendation, Ranking, and Anomaly Detection.

Supervised learning is a powerful tool for solving many real-world problems, such as image classification, spam filtering, and predictive maintenance. The key to success with supervised learning is having a large and diverse dataset to train the algorithm on, as well as carefully designing the algorithm itself to make the best predictions possible.

Unsupervised Learning

"In unsupervised learning, as you might guess, the training data is unlabeled. The system tries to learn without a teacher". — Hands on Machine Learning with Scikit-Learn, Keras and TensorFlow - Aurélien Géron.

Unsupervised learning is a type of machine learning in which the computer is given a dataset without any labeled data, and must find patterns and relationships in the data on its own. Think of it like being dropped in a new city and having to find your way around without any maps or guide. In the same way, the computer has to explore the data and figure out how it is organized without any help.

Unsupervised

For example, an unsupervised learning algorithm might be used on a dataset of customer purchase history to find patterns in the data. The algorithm might identify that certain customers tend to purchase certain types of products together, or that certain times of the year are associated with higher sales.

Unsupervised learning is very popular at solving problems like Clustering, Anomaly Detection, Dimensionality Reduction and Association, but it could also solve Recommendation and Ranking problems.

"The goal of an unsupervised learning algorithm is to create a model that takes a feature vector x as input and either transforms it into another vector or into a value that can be used to solve a practical problem." — The Hundred Page Machine Learning - Perter Norvig.

Unsupervised learning is used in many real-world applications, such as anomaly detection, market segmentation, and data compression. The key to success with unsupervised learning is to have a good understanding of the problem you are trying to solve and to choose the right algorithm for the job.

Semi-Supervised Learning

"Since labeling data is usually time-consuming and costly, you will often have plenty of unlabeled instances, and few labeled instances. Some algorithms can deal with data that's partially labeled. This is called semisupervised learning." — Hands on Machine Learning with Scikit-Learn, Keras and TensorFlow - Aurélien Géron.

Semi-supervised learning is a combination of elements from both supervised and unsupervised learning. In semi-supervised learning, the computer is given a dataset that has both labeled data and unlabeled data.

Think of it like having a teacher who provides answers for some of the practice problems, but not all of them. In the same way, the computer can use the labeled data to make predictions, but must also explore the unlabeled data to find patterns and relationships on its own.

Semisupervised

For example, a semi-supervised learning algorithm might be used to classify images into different categories. The algorithm might be given a small amount of labeled data, such as images with their corresponding labels, and a larger amount of unlabeled data, such as images without labels. The algorithm can then use the labeled data to make predictions about the unlabeled data, and can also use the patterns it finds in the unlabeled data to improve its performance.

Semi-supervised learning is useful in situations where there is limited labeled data available, or when the cost of labeling data is high. By combining the strengths of both supervised and unsupervised learning, semi-supervised learning can often achieve better results than either approach alone.

Semi-supervised learning is extremely useful for problems that require Classification and Clustering.

"In semi-supervised learning, the dataset contains both labeled and unlabeled examples. Usually, the quantity of unlabeled examples is much higher than the number of labeled examples. The goal of a semi-supervised learning algorithm is the same as the goal of the supervised learning algorithm". — The Hundred Page Machine Learning - Perter Norvig.

Reinforcement Learning

"Reinforcement Learning is a very different beast. The learning system, called an agent in this context, can observe the environment, select and perform actions, and get rewards in return (or penalties in the form of negative rewards). It must then learn by itself what is the best strategy, called a policy, to get the most reward over time. A policy defines what action the agent should choose when it is in a given situation." — Hands on Machine Learning with Scikit-Learn, Keras and TensorFlow - Aurélien Géron.

Reinforcement learning is a type of machine learning in which the computer learns by taking actions in an environment and receiving rewards or penalties for those actions.

Think of it like a child learning how to play a video game. The child tries different actions in the game, such as jumping or shooting, and receives points or loses lives as a result. Over time, the child learns which actions lead to success and which actions lead to failure, and adjusts their behavior accordingly.

Reinforcement

In the same way, a reinforcement learning algorithm takes actions in a virtual environment and receives rewards or penalties based on the outcomes of those actions. The algorithm uses this feedback to learn what actions lead to the highest rewards and adjust its behavior accordingly.

Reinforcement learning is used in many real-world applications, such as game playing, robotics, and autonomous vehicles. The key to success with reinforcement learning is to carefully design the reward function, which determines what the algorithm should be trying to optimize, and to make sure the algorithm has enough time to learn and explore the environment.

"Reinforcement learning is a subfield of machine learning where the machine “lives” in an environment and is capable of perceiving the state of that environment as a vector of features. The machine can execute actions in every state. Different actions bring different rewards and could also move the machine to another state of the environment." — The Hundred Page Machine Learning - Perter Norvig.

Types of Machine Learning Problems

The vast majority of problems that can be solved with Machine Learning can be classified into one of the following categories. If you know of any other type of problem that we have not included, write to us so that we can include it in the list.

  1. Regression: Regression is a machine learning problem that aims to predict a continuous value for a given input. For example, a regression algorithm might predict the price of a house based on its size, location, and other features.
  2. Classification: Classification is a machine learning problem in which the goal is to assign a class label to a given input. For example, a classification algorithm might predict whether an email is spam or not spam (also known as ham).
  3. Clustering: Clustering is an unsupervised machine learning problem in which the goal is to divide a dataset into groups, or clusters, based on similarity. For example, a clustering algorithm might group customers into different segments based on their purchase history.
  4. Optimization: Optimization is a machine learning problem that aims to find the best solution to a given situation. For example, an optimization algorithm might find the best set of parameters for a machine learning model or the best path for a robot to take to reach a goal.
  5. Dimensionality Reduction: Dimensionality reduction is a machine learning problem that aims to reduce the number of features in a dataset while preserving as much information as possible. For example, a dimensionality reduction algorithm might reduce thousands of features in a large dataset to just 10 for improved machine learning model performance and avoid redundancy.
  6. Anomaly Detection: Anomaly detection is a type of machine learning problem in which the goal is to identify data points significantly different from the rest of the data. For example, an anomaly detection algorithm might detect fraud in credit card transactions.
  7. Recommendation Systems: Recommendation systems are a type of machine learning problem that aims to recommend items to users based on their preferences. For example, a recommendation system might recommend books or movies to users based on their previous ratings.
  8. Sequence Prediction: Sequence prediction is a machine learning problem in which the goal is to predict the next value in a data sequence. For example, a sequence prediction algorithm might predict the next word in a sentence.
  9. Forecasting: Forecasting is a machine learning problem that aims to predict future values based on historical data. For example, a forecasting algorithm might predict future sales or stock prices.
  10. Generative Models: Generative models are a type of machine learning problem that aims to generate new data similar to existing data. For example, a generative model might be used to create new images or text that are similar to existing images or text. These are some of the most common types of machine learning problems, but there are many others.

Reinforcement

Extra Resources

Books

Chapter 1: In this chapter you’ll learn everything you need to know about Machine Learning, types of learning, examples, its challenges, and more. This is one of the MUST READ for machine learning developers.

Chapter 1: Quick and straight to the point introduction to Machine Learning, with some examples and a little introduction to mathematical notation.

Chapter 2: It contains a Terrific example about Advertising and strong mathematical foundations for anyone who is interested in learning how ML works in the inside. You’ll learn about Machine Learning, types of learning, error metrics, variance and bias trad-off, and more. This book is oriented for R enthusiasts but anyone could read it.

Videos