Machine Learning and its Types

Let’s familiarize ourselves with machine learning and its types, such as supervised, unsupervised, and reinforcement learning.

Before we start a machine learning project, we need a solid grasp on the theory behind that technology. In this lesson, we’ll briefly learn about the basic theoretical concepts necessary to understand the rest of the course. If you’re familiar with them, feel free to skip this lesson.

What is machine learning

The term machine learning was popularized by Arthur Samuel, a prominent figure in artificial intelligence. Samuel defined machine learning as “the field of study that gives computers the ability to learn without being explicitly programmed.” This was a revolutionary approach: traditional computer algorithms included all the necessary steps to be executed and were explicitly defined by a human programmer. Unfortunately, some problems are simply too difficult and complex, making it almost impossible to define an algorithm for them.

Machine learning can be used to circumvent that obstacle by training the computer to find the solution rather than giving it a set of explicit instructions. You may see machine learning being used interchangeably with artificial intelligence and deep learning. Although it is usually associated with the aforementioned terms, those terms aren’t identical. Machine learning is generally accepted as a subfield of artificial intelligence, while deep learning is a subfield of machine learning.

Machine learning categories

Machine learning is typically divided into three main categories:supervised learning, unsupervised learning, and reinforcement learning. We’ll look at a brief description for each one of those categories, as well as some real-life examples.

Supervised learning

The main goal in supervised learning is to create a predictive model based on a set of labeled instances that is known as the training dataset. This dataset is a matrix where rows represent the instances, while columns represent the features and labels. After the model is successfully trained, it can be used to make predictions on unlabeled data. Supervised learning is the most common type of machine learning, including tasks such as regression and classification. It can be applied to various kinds of data, like structured/tabular, text, image, video, and so on.

To help us understand supervised learning better, we’ll describe a simple regression example where the goal is to predict a continuous value. In this case, the training dataset includes cars with attributes like dimensions, horsepower, engine size, number of cylinders, and gas mileage. Those attributes will be used as features, and the price will be the label. After training, a regression model on that dataset will estimate the cost of a car based on the rest of its attributes. We’ll examine a complete case study of regression in the next chapter.

Let’s also consider a classification example, where the goal is to predict a categorical class label. The dataset comprises patient records, including attributes such as age, sex, resting blood pressure, chest pain type, and maximum heart rate. Those attributes are the features, while the presence or absence of heart disease in each patient is the label. This is known as a binary classification task because there are only two classes. The trained model, known as a classifier, will be able to evaluate whether a patient is at risk of having heart disease. We’ll cover classification in chapter 3 of this course.

Unsupervised learning

In case we can’t get a dataset with labeled instances, unsupervised learning algorithms can help us discover hidden structures on our data. Unsupervised learning includes tasks such as clustering and anomaly detection. Those algorithms can be applied to structured data, text, image, and other types of data, similarly to supervised learning.

Let’s consider the following clustering example. Suppose a company has a dataset with information about its customers, including various attributes, such as age, income, and spending behavior. Groups of customers with similar characteristics can be created with the help of a clustering algorithm in a process known as market segmentation. That information can be used to create effective marketing campaigns for each group, and so improve company sales and increase revenue. We’ll examine a clustering case study in chapter 4. Anomaly detection can be used in numerous different cases, such as fraud in financial transactions. In this case, every transaction is analyzed by an anomaly detection algorithm to detect potential fraud cases. Fraudulent transactions may include various possible events, like stolen credit cards being used for purchases or hackers attempting to transfer funds illegally. Every suspicious transaction will be flagged as such by the algorithm. We’ll study anomaly detection in chapter 5.

Reinforcement learning

Reinforcement learning aims to create an intelligent agent that interacts with its environment. That agent gets rewarded for every correct decision, and so it learns to perform various actions via trial-and-error. Reinforcement learning can be used to create autonomous vehicles such as self-driving cars. It can also improve the AI of video games and result in more immersive and realistic experiences for gamers. We will not examine reinforcement learning in detail because PyCaret doesn’t support it.