Many people feel that terms like "model," "big data," and "machine learning" are high-brow and mysterious. In fact, they are not much different from how we select fruit in our daily lives. This article uses a few thousand words to attempt to teach everyone how to select mangoes...
The Analogy of a Model
Suppose I want to find the delicious mangoes from a batch. Since I cannot directly cut them open to taste them, I can only observe the mangoes. The quantities I can observe include color, surface aroma, size, and so on. These are the pieces of information (features) we can collect.
There are many such examples in life, such as buying matches (perhaps young city dwellers have never seen matches?). How do you judge the quality of a box of matches? Do you strike every single match to see if it lights? Obviously not; at most, we can strike a few. If we strike them all, the matches are no longer matches. Of course, we can also look at the appearance of the matches and smell them; these actions are acceptable.
We might find that yellow, large mangoes are very sweet, but we also find that some not-so-yellow, small ones are also sweet. So, what are the respective proportions of features like color, aroma, and volume? If I can find these proportions, then I have found a method to predict whether a mango is delicious. The match example is the same: we can strike a few, see which ones light, and then summarize a method to predict whether they will light without striking them.
This is exactly what a model does. We first find a batch of mangoes (samples), record their features (color, aroma, volume, etc.), and then have someone taste them and evaluate which are delicious and which are not. Consequently, based on this batch of samples, we can summarize the proportions of color, aroma, and volume. This process of summarization is done by the machine itself.
Once finished, we obtain a model for predicting whether a mango is delicious. This is somewhat like a black box; in the future, by inputting data such as color, aroma, and volume, we can calculate the probability of it being delicious.
The Significance of Models
From the above analogy, it can be seen that the most important significance of a model is that it solves two problems:
1. "One-size-fits-all"
"One-size-fits-all" is a practice that often causes us much distress. For instance, in middle school, a teacher might "sentence us to death" without asking for the details; this simple and crude approach is a typical "one-size-fits-all" method. While such practices have a certain accuracy rate, not all problems can be solved this way. On the contrary, "one-size-fits-all" often mistakenly cuts out the "superior varieties"!
For example, if I want to find students with good grades in a class, we naturally think that academic performance is proportional to the time spent studying. Therefore, we assume that "studying more than 5 hours a day" defines a person with good grades. This is a "one-size-fits-all" approach. However, there are clearly some people who are naturally gifted or have highly efficient study methods; they spend only one hour a day and achieve excellent results. Such people are "cut out" by us, and clearly, what we are cutting out are the superior varieties.
2. Automatic Learning
Returning to the mango example: if we rely on "years of experience," we could figure out a set of methods for judging delicious mangoes even without a model. At this point, people might say, "What’s so great about your model? We can do very well ourselves." But what if I don’t want to eat mangoes anymore? What if I want to eat oranges or grapes? How do we predict the deliciousness of oranges and grapes then? We can’t wait many years to accumulate "years of experience" for lychees and apples, can we? Not to mention the time, it also consumes manpower.
Of course, others might have relevant experience with oranges and grapes, and we could consult them. But consulting has a cost—just think of the various paid training activities everywhere.
Models solve this problem perfectly. They allow us to start from a batch of existing samples (whether they are mangoes, apples, or lychees) and automatically, mechanically "summarize" (this process is called learning) a set of judgment methods. Since the learning is done by the machine, it saves us time and effort. We only need to make a cup of tea, wait for the model results to come out, and then see if the results are good. This is surely better than learning and summarizing ourselves and then judging our own learning effects.
How to Build a Model
To build a good model, there are generally the following steps:
1. Prepare Samples
Samples are the batch of "mango" samples we use for learning.
In fact, the process of building a model is very similar to the human learning process. If a human were to do it, we would certainly take a portion of mangoes first, record their features like color, size, and aroma, then cut them all open to taste them to see which are sour and which are sweet, and finally summarize the patterns.
For a model, the model replaces the human summarization process, which is the final step. The preceding preparation process still needs to be completed by us. We need to taste a batch of mangoes ourselves, record the information of that batch, and then input all this information into the model. The model can then learn automatically. Once learned, it can be used to predict the taste of new mangoes.
Preparing samples means preparing both good and bad samples. In other words, you need to find a batch of delicious mangoes and record their features, and you also need to find a batch of not-so-delicious mangoes and record their features. Only by telling the model all this information can it learn automatically. In this process, humans play the role of recorders.
2. Prepare Features
Features are the variables related to the judgment result and are the basis for model prediction.
Simply put, features are the "what" in the question of what mango deliciousness is related to. If we think the deliciousness of a mango is related to its size, color, and aroma, then "size," "color," and "aroma" are the features of the model—provided, of course, that this information is quantified.
There are good and bad features. Good features can help the model make correct predictions, while bad features are at least useless for prediction. For example, which tree the mango was picked from or which day of the week it was picked are probably not good features; that is to say, this information generally cannot help us judge the deliciousness of the mango. (Note the "generally"; it is not absolute. Perhaps mangoes picked from Tree A are indeed better than those from Tree B.)
Good features are crucial to a model. It can be said that finding good features (whether manually or by machine) is the most important part of modeling. A good data researcher should focus their main energy on feature selection during the modeling process; however, most researchers today often fall into a trap, spending a vast amount of energy on the model itself (i.e., Step 3).
3. Prepare the Model
Preparing the model is actually choosing the model—that is, what model to use for learning. This is like how people have different learning methods and experiences; it’s about choosing which method to use for learning.
In the actual field of machine learning, there are quite a few models. For example, they are divided into linear and non-linear models. Linear models include Logistic Regression, SVM, etc. Non-linear models include Random Forest, GBDT, Neural Networks, and so on. Regarding models, there are generally a few points to be clear about:
(1) The model is not the most important thing
In fact, the most important part of the modeling process is feature selection. If the correct features are selected, the difference in effectiveness between models will not be too large. Therefore, do not spend most of your energy on model selection.
(2) Prevent Overfitting
Overfitting is a phenomenon that is relatively difficult to detect. Generally speaking, it means the resulting model performs very well on in-sample tests but is a total mess in practical applications. Common methods to prevent overfitting include setting certain regularization coefficients (penalty functions) or setting a smaller depth (for decision tree-related models).
(3) Try to use linear models
Non-linear models, such as GBDT, generally perform better but are also more prone to overfitting. Therefore, if the effect of a non-linear model is not much better than a linear model, try to use a linear model because such models have better stability. This philosophy actually conforms to Occam’s Razor: "Entities should not be multiplied without necessity."
In the End
Of course, no matter what, it must be emphasized: Models are useful, but they are not omnipotent, nor are they the most important thing. Do not have blind faith in models and lose our own subjective initiative. A model can be said to be a work of art, provided that—you are an artist.
When reposting, please include the original address of this article: https://kexue.fm/archives/3390
For more detailed reposting matters, please refer to: Scientific Space FAQ