In the task of recognition, the key role is played by the selection of significant parameters of objects and the evaluation of their numerical values. Nevertheless, even having received good numerical data, it is necessary to manage to use them correctly. Sometimes it seems that the further solution of the problem is trivial, and one would like “from general considerations” to obtain a recognition result from numerical data. But the result in this case is far from optimal. In this article I want to show, using the example of the recognition problem, how you can easily apply the simplest mathematical models and thereby significantly improve the results.
These parameters can be represented as a numerical vector of a fixed dimension (for numerical parameters this is trivial, for the color / pattern of the iris / face image, etc., we must also figure out how to do this). That is, we have a certain number of classes X 1 , X 2 , ... X N , there is a prototype, described by a set of parameter values
, and we want to say about him if he belongs to one of these classes. Usually classes are presented in the form of several samples of this class: for example, visual images of an object from different angles, various measurements of parameters, and various copies of photographs of the iris. Then the simplest method of recognition is to compare the incoming object with each sample of each class, and by the distance from the nearest object, decide whether it is he or not.
This is quite a difficult task, especially when we have an unfixed number of classes: for example, when recognizing people, a person who does not exist in the database can pass - that is, a person of another class. But in fact, we calculate the difference dx between the object under study and the sample class and make a decision, is it the same or different object. For example, if we want to recognize a person by fingerprints, then we compare the resulting fingerprint with all fingerprints from a certain database, calculate the measure of similarity between each pair of fingerprints, and according to this measure of similarity for the most similar fingerprint, decide that this is the same Man, if the prints are similar enough, or that this person is not in our database, if the most similar imprint is still not similar. That is, our classifier takes as input not the parameters of the object x, but the difference between the parameters of two objects dx = x - x i (it is better to even take the difference module of each component so that the order of subtraction is not important), and by these parameters it gives a characteristic (measure of similarity ), allowing to make a decision: are they the same objects or different.
This can be viewed as a classification task with two classes: “identical pairs of objects” and “different pairs of objects”. And the class of "identical pairs" will be heaped closer to zero, and different - on the contrary, they will be somewhere aside. Traditionally, the classifier should produce a numerical measure of similarity (for example, from 0 to 1), which is greater, the greater the likelihood that these are different objects; Further, depending on the requirements of the system, a threshold is determined for making a decision, on which errors of the first and second kind depend.
. That is, as the Euclidean distance between the samples, if the parameters are considered as coordinates. The smaller it is, the more “similar” these two objects are, that is, there is a greater chance that they are the same. This is correct, but with a number of limitations: all parameters must be uncorrelated (mutually independent), they must have the same distribution (they must be equivalent). This is usually not the case (for example, height and weight should not be considered independent, and the shape of the nose is a much more reliable characteristic than the shape of the mouth or the length of the hair). Then let the different components choose different weights to strengthen the more important parameters and weaken the less important ones:
.
), while still they should be less if the variance is very large, that is, the components are more noise than informative. All my attempts at optimization at this stage led to the need to take one most important component, and not to consider the rest, which obviously will not give a good result. In the end, I scored on the dispersion and just counted for each component
, the exponent k was chosen experimentally, and for different sets of parameters the best indicator could turn out to be equal to both 0.01 and 4.
(yes, it looks very similar to those weights).
Finding such a function is called linear regression. The coefficients b 0 , b 1 , ... b n will be chosen in such a way that this OLS function best suits the correct values ​​for the test sample. And the correct values ​​are Y = 0 for identical objects and Y = 1 for different. Intuitively, it seems that the value of b 0 must be equal to 0, because on the zero vector of difference we have guaranteed identical objects. But we will not play a guessing game and calculate b 0 to be honest. Thus, we essentially define the direction in the n-dimensional space in which the same and different pairs will differ most strongly.
. Hereinafter, M is the number of test sample objects, the superscript denotes the number of the object in the sample, the superscript is the number of the object's components. This error is minimized at the point at which the derivative for each component is zero. Elementary mathematics leads us to the system Ab = f, where A is the matrix (n + 1) * (n + 1),
,
,
, i, k = 1..n.
,
. We calculate the elements of the matrix by the test sample, we solve the system, we get the coefficients, we build the function.
Or you can choose a certain number of the most significant parameters (for example, weed out those whose average value for different does not exceed the average value for the same, or the dispersion is too large). And since no one reads the entire article, I propose to select parameters that have the most beautiful numbers, for example, that end in a seven.
Source: https://habr.com/ru/post/205428/
All Articles