(4) Classification of machine learning methods


  In the previous blog, I mainly introduced the two tasks of machine learning, classification tasks and regression tasks. This is mainly from the perspective of the problem that machine learning can solve, not from the machine learning algorithm itself. If we focus on the machine learning algorithm, we can divide the machine learning algorithm into There are four categories of supervised learning, unsupervised learning, semi-supervised learning and reinforcement learning.

1. Supervised learning


  The so-called supervised learning is that the training data set we give the machine is "marked" or "has the answer". For example, whether it is the flower data set or the real estate data set mentioned before, at the end of the data set, there is a column for labeling. I will call this column y, if the data we give to machine learning is such data It is called supervised learning.

  In other words, we want to identify whether this photo is a cat or a dog in image recognition. It is not enough that we only give this photo to the machine. At the same time, for each photo, for example, in the following photo, we need to tell The picture on the left is a dog, and the picture on the right is a cat.
Insert picture description here
  In the same way, for the MINST data set, the following pictures only show the information of each picture in the MINST data set, which is the information of X that we said before.
Insert picture description here

  But at the same time, for each picture information, a tag information should be attached.
Insert picture description here
  If the data we give the machine is such data, there are both X and y, both the characteristics of the data itself, and the labels corresponding to the data , then it is called supervised learning . Here, the meaning of supervision is actually that we humans have divided the correct answer for this data to the machine, and this correct division is itself called supervised information. Think about it. In real life, many learning processes are supervised learning processes. For example, images already have calibration information; banks have accumulated certain customer information and their credit card credit status; hospitals have accumulated Certain patient information and their final diagnosis of illness; the market has accumulated basic information about the house and the final transaction amount, etc.

  For supervised learning, it mainly deals with two categories of problems, namely classification problems and regression problems . Most of the algorithms learned later are supervised learning algorithms. Such as k nearest neighbors, linear regression and polynomial regression, logistic regression, SVM, decision tree and random forest. But it does not mean that unsupervised learning is not important.

2. Unsupervised learning


  Understand supervised learning, then it is easy to understand unsupervised learning. Unsupervised learning is to give machine training data without any "marks" or "answers". Unsupervised learning can classify data without "labels", which is usually called cluster analysis.

  For example, each of our customers visits an e-commerce website, browses different product information on this e-commerce website, buys different products, and leaves some behavioral data. In fact, the e-commerce website treats each of us equally, the initial At that time, there is no such mark for everyone, but as we leave more and more footprints on the e-commerce website, the e-commerce website can use this unsupervised learning algorithm for its customer base In classification, some groups may be considered as rational consumers, some are artificially impulsive consumers, some people pay more attention to cost performance, and others pay more attention to quality.
Insert picture description here
  Another very important function that unsupervised learning can accomplish is to reduce the dimensionality of the data . It mainly includes feature extraction and feature compression . The so-called feature extraction, when we face a piece of data, the data has many features. Sometimes, based on our experience or in-depth analysis, we may think that certain features are the final result of our prediction or calculation There is no contribution. To give a simple example, the bank may perform a credit rating based on the credit card of different people. The information of different people may include information such as the person's weight. Imagine that a person's fatness and thinness seem to be different from the person's credit. It doesn't matter, then in this case, we can throw away this kind of information directly, which is called feature extraction. Another very important work is called feature compression. Feature compression means that we don't throw away any features, but sometimes the correlation between features is very strong. To give a simple example, as mentioned before to recognize a handwritten number, 28*28 feature points are required to mark, then we can use feature compression, it is possible to use dozens of points or more than a dozen points. The representation. Therefore, feature compression is a very effective tool when we face high-dimensional data. One of the main methods used for feature compression is PCA. To summarize briefly, what feature compression does is to reduce high-dimensional feature vectors to low-dimensional feature vectors with as little loss of information as possible. This way, for many tasks, it can greatly improve the operation of our machine learning algorithms. Efficiency, however, does not affect the accuracy of the final prediction of machine learning.

  Then the dimensionality reduction of the data has another very important meaning: to facilitate visualization . This is because it is difficult for us humans to understand information such as space above four dimensions, and in order to be able to see this information intuitively, sometimes we can reduce high-dimensional data to three-dimensional or even two-dimensional. So it is very likely that a lot of information will be lost if you drop to such a low dimension, but it doesn't matter, we drop to such a low dimension, mainly for us to visualize the data, so that we can intuitively have a certain understanding of the data.

  In addition to dimensionality reduction, unsupervised learning can also perform anomaly detection . The so-called anomaly detection, sometimes in our data, there are some points, these points are obviously abnormal, so here is an example.
Insert picture description here
  In a two-dimensional space, these two red dots are a little far apart from these blue dots. If they belong to one type of data, we can consider these two red dots to be abnormal points. For such abnormal points, it is not that they are meaningless, but we can see that they are not meaningful by looking at them intuitively. Can not express a characteristic of this sample as a whole. For our machine learning, we often need to find the generalized characteristics of our sample, so for this special point, it is very likely that it will not help our algorithm to find this generalized law. , So we usually need to remove this abnormal point. Of course, for this data is only a two-dimensional data, we can directly observe it with the naked eye, but for a high-dimensional data, we need to use the corresponding algorithm in unsupervised learning to help us eliminate these anomalies Point for anomaly detection.

Three, semi-supervised learning


  Let's look at another type of machine learning method, semi-supervised learning . In fact, part of the data has "marks" or "answers", and the other part does not.

  In fact, this situation is more common in our lives, because the data is often missing markers due to various reasons. Correspondingly, the complete labeling of a data set usually requires a company or enterprise to invest manpower, material resources and financial resources to carry out such data labeling tools, so that all data can be marked. Usually for semi-supervised learning, we usually use unsupervised learning methods to process the data first, and then use supervised learning methods to train and predict models.

Four, enhanced learning


  The last method of machine learning is reinforcement learning . That is, take actions based on the surrounding environment, and learn how to act according to the results of the actions.

  Reinforcement learning refers to our machine learning algorithm. At this time, this algorithm is usually called Agent. We must act according to the surrounding environment. After we take action, our algorithm will receive some feedback accordingly. Sometimes we use reward (reward) mechanism to provide feedback, and sometimes we use punishment. No matter what, when our Agent algorithm gets feedback, he will improve his behavior mode, and then he will make corresponding actions based on this improved algorithm in other situations in the environment. Then the environment is fed back to our Agent, and so on. Through this process, it can be seen that the Agent gradually enhances its intelligence through such rounds of actions and feedback.
Insert picture description here
  In fact, Alpha Go is a typical application of reinforcement learning. The most cutting-edge unmanned driving is to study robots with strong artificial intelligence, and they all need to enhance the knowledge of this field.

Five, other classifications of machine learning


We have another dimension to classify machine learning, namely online learning and batch learning (offline learning) . Parametric learning and non-parametric learning .

1. Batch Learning

  In fact, the concept of batch learning is very easy to understand. The algorithm we introduced before can use batch learning to perform machine learning without special instructions. The so-called batch learning is that we first collect a certain amount of sample data, and then These sample data are sent to our machine learning algorithm, and our machine learning algorithm can train a model. After we produce such a model, we can directly put this model into the production environment, in the new production environment In the environment, new samples will be sent in, and then the corresponding results will be predicted through this model. During this process, our model will not change any more.
Insert picture description here

  For batch learning, its advantage is that it is very simple, but it also has an obvious problem, that is, how to adapt to environmental changes ? As mentioned before, for machine learning, a very big problem is that the content of learning may be constantly changing over time. For example, for spam processing, as time changes, new Spam emails are constantly emerging. The style of spam next year may be different from this year's. So we trained a spam recognition system this year. We hope it can be used for 3 years, 5 years, or even longer. not realistic. For the example of spam, the speed of change is relatively slow, so we can adopt a very simple solution: re-learning in batches regularly . In other words, we can formulate every three months to merge the new sample data and the original samples during these three months to form a new learning data set, and then re-execute it on the new data set Machine learning algorithms retrain our models to adapt to changes in the environment. But this scheme also has an obvious shortcoming that each time it re-learns in batches, the amount of calculation is very large. And in some cases where the environment changes very quickly, batch learning is impossible. For example, batch learning is required every day, but the time for batch learning each time cannot be completed within 24 hours. In this case, it is unrealistic to use batch learning.

2. Online Learning

  To give another example, if we use batch learning for stock market analysis, the stock market is constantly changing every minute and every second. If we want our algorithm to adapt to changes in the environment in time, we need to use online learning. Use the newly generated data in a timely manner to improve the machine learning model.

Insert picture description here
  The advantage of online learning is obviously to reflect new environmental changes in a timely manner , but it also has a new problem, that is, will new data bring bad changes ? For example, it is possible that the new data obtained by the machine learning algorithm that we deploy in the production environment is not normal data due to the equipment. Then these abnormal data will enter the machine learning algorithm very quickly. It is used to train our model, but the accuracy of our model for events drops. Or even sometimes, our competitors deliberately use some wrong ways to use our system, but because our system uses online learning methods, they will learn these wrong ways and get inaccurate results. The solution to these problems is usually to strengthen the monitoring of data . One of the usage scenarios in the unsupervised learning mentioned earlier is to detect abnormal data. Usually, in the online learning process, we need to detect abnormal data in time. On the other hand, online learning can not only reflect new environmental changes in a timely manner, but also apply to environments where the amount of data is huge and batch learning is completely impossible.

  From another dimension, machine learning can be divided into parametric learning (Parametric Learning) and non-parametric learning (Nonparametric Learning).

3. Parametric Learning

  So what is parameter learning? The following figure shows a two-dimensional space. We can assume that the abscissa is the area of ​​the house, and the ordinate is the price of the house. Each corresponding house is a corresponding point in the two-dimensional space. For these data points, I can assume that there is a linear relationship between the area and the price of the house. In other words, I first assume the price f(x) = a * x + bof the house, and x is the area of ​​the house. Then the whole machine learning process is to find a good a and b to describe the relationship between the area of ​​the house and the price of the house, then the a and b are the parameters. Such a machine learning process is called parameter learning, and a feature of parameter learning is that once the parameters are learned, the original data set is no longer needed .
Insert picture description here

4. Non-parametric learning

  The so-called non-parametric learning is not to make too many assumptions about the model. But one thing to note here is that non-parameter does not mean no parameter! The difference here is that I do not model the whole problem, and do not understand the whole problem as learning some parameters, but in the learning process, parameters are still required to participate.

Guess you like

Origin blog.csdn.net/qq_41033011/article/details/108910406