Introduction to Machine Learning: Understanding the Algorithms that Drive Artificial Intelligence

The word “learning” always refers to the human ability to acquire new skills or knowledge from experiences. However, what if we say that machines can also learn? This is not a fantasy of science fiction, but a powerful reality in our modern world, known as machine learning, one of the pillars that defines the revolution of Artificial Intelligence (AI).

By understanding how machines learn and evolve, we open doors for innovations that were previously inconceivable. This article is a journey of discovery through the fundamental concepts and algorithms of machine learning, designed to transform beginners into informed enthusiasts of AI.

What is Machine Learning?

Machine learning is a subfield of AI that gives computational systems the ability to learn and improve from experiences without being explicitly programmed for it.

It is about granting machines the ability to make predictions or take decisions based on the analysis of large data sets. A simple music or product recommendation, to the early identification of diseases, are all practical examples of how our lives are already being shaped by machine learning algorithms.

How do Machines Learn?

The learning of a machine starts with data – lots of data. Just as children learn to recognize a dog by seeing various examples of different breeds and sizes, machines require data to identify patterns and make generalizations. It is an iterative process; the more quality and diversity of data they receive, the better becomes the ability of the machine to perform its tasks.

Types of Machine Learning

There are three main types of machine learning: supervised, unsupervised, and reinforcement. Each type has its own objectives, methods, and algorithms. The chart below illustrates the main types, categorizing and giving examples of applications.

machine learning ai

Supervised Learning

Supervised learning is the most common and simple type of machine learning. In this type, we have a labeled data set, that is, each data has an input and an expected output. The goal is to find a function that maps the inputs to the outputs, so that the function can predict the outputs of new inputs.

For example, if we have a data set with images of cats and dogs, and we want the machine to recognize which animal is each image, we can use supervised learning to train a model that receives an image as input and returns a label (cat or dog) as output.

For example, a labeled data set of images of cats and dogs can have the following format:

[image,class]
[image of a cat, cat]
[image of a dog, dog]

In the above example, the class “cat” is the desired output for the image of a cat.

Supervised learning is used in a wide range of tasks, including classification, regression, and clustering.

Examples of classification problems that can be solved with supervised learning:

  • Identify if an image is of a cat or a dog;
  • Identify if a customer is about to cancel their subscription;
  • Identify if a patient has cancer.

Examples of regression problems that can be solved with supervised learning:

  • Predict the price of a stock;
  • Predict the demand for a product;
  • Predict the lifespan of a person.

Examples of clustering problems that can be solved with supervised learning:

  • Group customers based on their buying habits;
  • Group products based on their features;
  • Group genes based on their function.

The main algorithms of supervised learning are:

  • Linear regression: an algorithm that finds a line that best fits the data, in order to minimize the error between the actual values and the predicted values. Linear regression is used for regression problems, that is, when the output is a continuous value, such as the price of a house or the grade of a student.
  • Logistic regression: an algorithm that finds a sigmoid curve that best fits the data, in order to maximize the probability of hitting the labels. Logistic regression is used for binary classification problems, that is, when the output is a discrete value with two options, such as yes or no, positive or negative, cat or dog.
  • Decision tree: an algorithm that builds a hierarchical structure of questions and answers, that lead to a final decision. The decision tree is used for classification or regression problems, with discrete or continuous outputs, and can handle categorical or numerical data. For example, if we want to decide whether a person should or should not play tennis, we can use a decision tree that asks questions about the weather, the temperature, the humidity and the wind, and returns an answer (play or not play) in each leaf of the tree.
  • K-nearest neighbors (KNN): an algorithm that classifies a new input based on the proximity to the already known inputs. The KNN is used for classification problems, with discrete outputs, and can handle categorical or numerical data. For example, if we want to classify a flower as one of the three species of iris, we can use the KNN to compare the measurements of the flower (length and width of the sepal and petal) with the measurements of the already labeled flowers, and choose the species that most repeats among the K closest flowers.
  • Support vector machine (SVM): an algorithm that finds a hyperplane that separates the data into two classes, in order to maximize the margin between them. The SVM is used for binary classification problems, with discrete outputs, and can handle numerical data. For example, if we want to classify whether a tumor is benign or malignant, we can use the SVM to find a hyperplane that separates the tumors based on their characteristics, such as the size, the shape and the texture.
  • Artificial neural network (ANN): an algorithm that simulates the functioning of the human brain, with layers of neurons connected by weights. The ANN is used for classification or regression problems, with discrete or continuous outputs, and can handle categorical or numerical data. For example, if we want to recognize handwritten digits, we can use an ANN to receive an image as input, process it through several layers of neurons, and return a digit as output.

Unsupervised Learning

Unsupervised learning is the most complex and challenging type of machine learning. In this type, we have an unlabeled data set, that is, each data has only an input, without an expected output. The goal is to find patterns, structures or clusters in the data, in order to extract useful information or reduce the dimensionality.

For example, if we have a data set with the characteristics of various customers, and we want to segment them into homogeneous groups, we can use unsupervised learning to find the grouping criteria and the profiles of each group.

Now going back to the cats and dogs, an unlabeled data set of images of cats and dogs can have the following format:

[image]
[image]
[image]

In the above example, the goal of the machine learning algorithm is to identify patterns in the unlabeled data so that it can learn to distinguish cats from dogs.

Unsupervised learning is used in tasks such as clustering, dimensionality reduction and outlier detection.

Examples of clustering problems that can be solved with unsupervised learning:

  • Group customers based on their demographic data;
  • Group products based on their features;
  • Group genes based on their function.

Examples of dimensionality reduction problems that can be solved with unsupervised learning:

  • Reduce a high-dimensional data set to a low-dimensional data set;
  • Eliminate noise from a data set.

Examples of outlier detection problems that can be solved with unsupervised learning:

  • Identify data that are out of the curve;
  • Identify invalid data.

The main algorithms of unsupervised learning are:

  • K-means: an algorithm that divides the data into K groups, in order to minimize the distance between the data and the centers of the groups. The K-means is used for clustering problems, that is, when we want to separate the data into distinct subsets, without knowing beforehand what these subsets are. For example, if we want to group the customers of a store into K profiles, we can use the K-means to find the centers of the profiles and assign each customer to the closest profile.
  • Principal component analysis (PCA): an algorithm that reduces the dimensionality of the data, in order to preserve most of the variance. The PCA is used for dimensionality reduction problems, that is, when we want to simplify the data, eliminating the less relevant or redundant features. For example, if we have a data set with 100 features, and we want to reduce it to 10 features, we can use the PCA to find the 10 linear combinations of the original features that best explain the variance of the data.
  • Hierarchical clustering: an algorithm that builds a tree structure of the data, in order to show the proximity relations between them. The hierarchical clustering is used for clustering problems, when we want to visualize the data in different levels of granularity. For example, if we want to group the countries of the world into continents, regions, sub-regions etc., we can use the hierarchical clustering to create a dendrogram that shows the distances between the countries and the clusters at each level.
aprendizado de maquina machine learning inteligencia artificial 2

Reinforcement Learning

Reinforcement learning is the most dynamic and interactive type of machine learning. In this type, we have an agent that interacts with an environment, and receives rewards or punishments for its actions. The goal is to find a policy that maximizes the expected value of the rewards in the long term.

For example, if we want the machine to learn to play chess, we can use reinforcement learning to train an agent that receives the state of the board as input, chooses a move as action, and receives a reward or punishment as output, depending on the outcome of the game.

Examples of problems that can be solved with reinforcement learning:

  • Play chess;
  • Play soccer;
  • Drive a car;
  • Control an industrial plant.

The main algorithms of reinforcement learning are:

  • Q-learning: an algorithm that learns a function that estimates the value of each action in each state, in order to choose the action that maximizes the future value. Q-learning is used for optimal control problems, that is, when we want to find the best action for each situation. For example, if we want the machine to learn to drive a car, we can use Q-learning to train an agent that receives the traffic situation as input, chooses an action such as accelerating, braking or turning, and receives a reward or punishment as output, depending on the safety and efficiency of the action.
  • Policy gradient: an algorithm that learns a function that estimates the probability of each action in each state, in order to choose the action that maximizes the average reward. Policy gradient is used for stochastic control problems, that is, when we want to find the best action for each situation, considering the uncertainty and variability. For example, if we want the machine to learn to play a board game, we can use policy gradient to train an agent that receives the state of the game as input, chooses an action such as moving a piece, and receives a reward or punishment as output, depending on the outcome of the game.
  • Deep reinforcement learning: an algorithm that combines reinforcement learning with deep learning, using artificial neural networks to represent the value or policy functions. Deep reinforcement learning is used for complex control problems, that involve high-dimensional states and actions, and that require generalization and abstraction. For example, if we want the machine to learn to play a video game, we can use deep reinforcement learning to train an agent that receives the screen of the game as input, chooses an action such as pressing a button, and receives a reward or punishment as output, depending on the score of the game.

Conclusion

Although this is just the tip of the iceberg of machine learning, it is clear that its impact is already felt in almost every aspect of our lives. As technology advances, the ability of machines to learn and adapt will continue to open new horizons, revolutionizing the world as we know it.

In this article, we saw what machine learning is, one of the main areas of artificial intelligence, that studies how machines can learn from data and perform complex tasks. We also saw what are the types of machine learning (supervised, unsupervised and reinforcement), and what are the main algorithms of each type. We saw examples of problems that can be solved with machine learning, such as classification, regression, clustering etc.

I hope you enjoyed the article and that it was useful and interesting for you. If you liked this article, share it with your friends and keep following our blog for more content on artificial intelligence and technology. Thank you for your attention and see you next time!