When talking about Machine Learning we always talk about "trained model" or "training a model" but…what exactly does that mean?
What is a trained model? What do we do when we train models? Do we always have to train a model?
In this article, we will answer all these questions, talking about supervised and unsupervised learning, and we’ll see in what sense training a Machine Learning model is different from training a human.
1. Training an ML model is not the same as training a human (or an animal)
If we search in a dictionary for the verb "to train" we’ll find something like:
teach (a person or animal) a particular skill or type of behaviour through practice and instruction over a period of time
But there is something more to it. In fact, I prefer:
a: to teach so as to make fit, qualified, or proficient
b: to form by instruction, discipline, or drill
c: to make prepared (as by exercise) for a test of skill
These three have "a hidden" meaning: when a person (or an animal) is trained he/she/it becomes, at a certain point, independent. I mean that the trained person/animal at a certain point can complete the tasks is trained for on his own (without the trainer).
For example, if you have ever tried any sport you know how it works: at the beginning, the trainer helps you in the first movements, even helping you physically. Then, at a certain point (when you are trained!) you go on your own!
So, how do we train computers?
Training an ML model does not mean taking a robot, getting it on a bicycle, and training it to cycle moving its legs and telling it "Move your legs up and down and you’ll go!". This is what we do with humans, but humans (and animals) are far different from computers.
So, when training an ML model we have to split the discussion into two parts:
- supervised learning
- unsupervised learning
Let’s see the details.
2. Training an ML model: supervised learning
Supervised Learning (SL) is intended as the way an ML model is trained by a human being. This means that the human (the Data Scientist, the Machine Learning Engineer, or whatever it is) trains the ML model in a set of known data. In other words, quoting Wikipedia:
Supervised learning is the machine learning task of learning a function that maps an input to an output based on example input-output pairs
So, in Supervised Learning, we have a set of data in which we know the input and the output (we also say: data is labeled) **** and we train the ML model in predicting the output of unseen data.
Let’s make a simple example. Consider a simple classification problem, for example, this simple project I made. Here I had a dataset related to diabetes: the inputs are various medical conditions of patients and the output is: the patient has diabetes (1) the patient hasn’t diabetes (0). This means an important fact: someone has measured the patients’ conditions and has stored them somewhere, also reporting if they had diabetes or not. The aim of an ML model, in this case, is to predict if a patient may have diabetes or not, given some input conditions (the medical conditions he/she may have).
In this case, I’ve trained two different ML models (K-nearest neighbor and Decision Three) to decide which one gives the best performance on unseen data. But if we have a dataset of known data, how do we work with unknown data? Well, the process of training an ML in the supervised case is pretty simple:
- we get the dataset and we know the input and the output
- we split the dataset into two datasets: a training dataset and a test dataset
- we train the ML models on the training dataset
- we evaluate the performance of the ML models on the test data.
So, the test data is the unseen data ("unseen" for our ML model) and we can evaluate the performance of our ML models and choose the one we believe is the best.
So, in Supervised Learning, you explicitly tell the ML model the output that it is supposed to produce for each input, and, if it does not produce it, then you adjust its (hyper)parameters so that next time it is more likely to produce the correct output for that input.
This is the essence of training an ML in the Supervised Learning case: adjusting the (hyper)parameters (also called "hyperparameters tuning") so that the ML model produces an output that is as near as possible to the desired output (which is known!).
3. Training an ML model: unsupervised learning
In the Unsupervised Learning (UL) case the data are not labeled. If we think about the previous case, where we had a dataset of patients’ health conditions and we knew if they had diabetes or not, in an unsupervised learning case we would just have the patients’ medical conditions. Period. We wouldn’t know anything about their (possible) diabetes condition.
So, how does the training work in this case?
Unsupervised learning uses machine learning algorithms to analyze and cluster (meaning "grouping") unlabeled data sets. These algorithms discover hidden patterns in data without the need for human intervention, and this is why the case is "unsupervised". So, Unsupervised Learning models work on their own to discover the "innate" structure of unlabeled data. This means a simple thing: there is no training on the Unsupervised Learning case. In this case, the algorithm works on its own on finding how to group the (unlabeled) data, so the human doesn’t train the model.
Conclusions
In this article, we have learned an important concept in machine learning; it is what we call "training". Training an ML model means that the human behind the screen adjusts the hyperparameters of the model so that the model can predict the output as near as possible as the real outputs. This means that we, as the humans (the trainers), have to know the actual outputs, and this is why we train ML models only in what we call "Supervised Learning".
In Unsupervised Learning, the ML model learns on its own and there is no need for training. Of course, when possible, it is always a good idea to evaluate what our Unsupervised Model has done; to do that, we train a Supervised ML model on known data (but, as I said before, it is not always possible to do that…otherwise, there would not be the need for Unsupervised Models!).
Let’s connect together!
LINKEDIN (send me a connection request)
If you want, you can subscribe to my mailing list so you can stay always updated!
Consider becoming a member: you could support me and other writers like me with no additional fee. Click here to become a member.