How do machines learn? A step into machine learning

Lucas Miranda de Sena
4 min readMar 25, 2024

--

What is Machine Learning?

Machine learning is a field of computer science that, unlike traditional computing where every action needs to be explicitly programmed, is focused on developing algorithms and mathematical/statistical models capable of “learning” the behavior of a phenomenon or identifying similarities from previous data, thus being able to make predictions about the phenomenon or diagnose it.

How do machines learn?

Could a fotographic memory save you in an exam? Well, without understanding the subject, it’s likely that it wouldn’t help you much, because your knowledge would be limited to exactly what you memorized — input of data. It is more effective to understand the general concepts and main ideas, so that we can abstract rather than trying to memorize everything that exists. Machines learn in a similar way.

MAGRITTE, René. La trahison des images. 1929.

Although it is written “This is not a pipe,” we recognize that it is. Our brain is capable of abstracting a painting because it has been exposed to images of pipes from different angles for years, being able to generalize to recognize pipes of different colors, sizes, and shapes. Training a machine learning model on a dataset is called training. Thus, it can search for key concepts in the abstracted data during training (pipes have a mouth, stem) to make decisions — to generalize. Just like our learning is related to what we are exposed to, the machine is too. The model will be as good as the data that was used for its training. If a facial recognition algorithm is trained using only people without glasses, when it sees a person with glasses, it will not say it’s a face. It is not able to generalize well. We say that, in this case, the data has bias.

LANTZ, Brett. Machine Learning With R.

Types of learning

For each type of situation, there is a more suitable learning approach that will involve different steps. The three ways a computer learns can be divided into supervised learning, unsupervised learning, and reinforcement learning.

Supervised learning: is so named because it is like learning from a teacher. The data used for learning already provides examples of the phenomenon to be learned, such as the price of a property, and other features that may or may not influence it, such as its size, location. In this example, the goal of the algorithm would be to predict the value of a new property based on the provided characteristics.

Unsupervised learning: this time there is no teacher, as there is no phenomenon to be predicted or classified. The goal is to identify patterns in the provided data. For example, in a database of customers from a retailer, groups of customers more similar to each other could be identified based on their previous purchases, and grouped to target promotions more effectively.

Reinforcement learning: similar to supervised, there are examples of the studied phenomenon in the database, but there is one more step. The output of the algorithm is always evaluated and compared to a possible expected result, such as a reward or penalty, in order to adjust the algorithm’s parameters and obtain a better result. It’s like training a dog.

Learning stages

Data acquisition: data can be available in structured form — xlxs files, SQL database, semi-structured — json and xml, and unstructured — images and text.

Exploration, cleaning, and data treatment: again, a model will be as good as the data that was used for its training. This is the stage where you get to know the data and a good part of your time will be spent here, if not the most. In this process, the presence of outliers, missing values, normality of distributions should be checked. Questions should be asked and statistical tests performed. Correlation between predictor and predicted variables. Standardization or normalization of variable dimensions, encoding and choosing which ones can or cannot be eliminated from the database (feature engineering).

Training the model on the data: the technique is chosen according to the problem — there is no perfect technique. At this point, the model is adjusted to the dataset that was processed in the previous step. The relationship between the variables is mapped (inputs and outputs) to “learn” key concepts. The trained model represents the dataset it received.

Testing and validation: after training, the model receives data that was not seen during training. There are metrics for evaluating the quality of a model’s output, such as accuracy, recall.

Optimization: the result that the model delivers in the test is not final. Each technique has parameters to be chosen for learning that will influence its result, such as the depth of a decision tree and the method of distance calculation in KNN.

Deployment: after fine-tuning the model, it can be put into production to make real-time predictions, classifications, or diagnoses. A model can be hosted in a cloud environment, implemented in software.

References

LANTZ, Brett. Machine Learning With R.

--

--

Lucas Miranda de Sena

Hello! I’m, Lucas. I’m a data scientist passionated about learning. My goal here is to share and learn with you guys.