




























































































Studia grazie alle numerose risorse presenti su Docsity
Guadagna punti aiutando altri studenti oppure acquistali con un piano Premium
Questa pagina non è visibile nell’anteprima
Non perderti parti importanti!





























































































Machine Learning (ML) is linked to the ability of machines to learn automatically starting from examples that are shown to them. The idea of pattern , which is the regular and repeated way in which something happens or is done, makes us understand that we often have to look at things over and over and repeat them to understand how they work and the laws that govern their behavior. Machine Learning and Pattern Recognition involves the recognition of these patterns, so repetitions of data among the very large quantities that are available. ML means learn from data; there exists 2 main ways of learning:
model, trying to optimize the results and the performance on those data, some data will be used to validate and test the model and, therefore, check if you get more or less similar performance even with data not seen / used yet (to make sure the model is not simply memorizing the input values, i.e. overfitting ). Overfitting: the derived model reproduces exactly the data used during the training phase (good performance), but it works completely incorrectly with other (test) values (bad performance); essentially the algorithm just memorizes the input data, it does not make any generalization. Classification As in the regression, there are pairs of input and output values, with the difference that in this case the output is a label; therefore, to each input is associated a suitable label chosen from a finite set of possible labels. The main difference between regression and classification is that in the first one, usually, the domain of the function is continuous (typically real), while the domain of the set of labels of a classification problem is discrete, because it is a finite set of integer numbers or symbols. What you want to achieve in a classification task is a mapping that associates the right, appropriate label to each value passed as input. Also in this case we want a model that is able to generalize the data and not just memorize it, that is, the mapping must maximize the precision with which the correct label is assigned to the correct sample, and so we want to maximize accuracy (i.e. the number of correct classifications of the training data). Classification is the main problem of Pattern Recognition: usually you want to recognize and classify some patterns because they represent something. A practical example is to observe a set of objects and labels that have been assigned to them and try to assign an appropriate label to other objects, not seen in the training phase, based on the similarity of the new objects with those already seen.
Classification and Regression are supervised learning problems because, in the training phase in which a data model is generated, the desired output we want the model to produce when applied to each input instance is specified and, for that reason, it is usually called teaching input. In fact it is a part of the input we provide to the learning algorithm and it is used to teach the model how to “behave”. As we already said, in regression problems, the teaching input is typically continuous (a real number) and our model is a real function of typically real variables (inputs are usually vectors in R n ). In classification problems, the teaching input belongs to a discrete domain (an integer number or a symbol from a numerable set) and the model is a mapping from a typically continuous domain. This is a crucial difference that is reflected in the structures of the algorithms and the solutions in the two cases. Solving real-world problems usually implies: ● observing few instances of a problem / phenomenon (patterns, examples, usually a vector of features): experience ; ● deducing the best possible solution, which can be applied successfully to all possible problem instances: learning and generalization. This is often obtained by building a model which fits data as closely as possible (modeling experience): we want to model what we experienced, optimizing some quality criterion. For both problems (regression and classification), most of the data must be used for training the model being built, but a part of them must be kept aside to later verify that the model works correctly. Since we want to replicate some behavior, we rely on criteria that indicate whether this is done accurately and correctly or not: we try to optimize a certain quality criterion. Very often strategies derived from the theory of evolution are used rather than mathematical properties, in order to try to achieve an optimal behavior. One might think that using the same data always leads to the same result; actually this is not true. In fact, the same data can be used to find solutions to different problems, that is, they can be used to train models with different objectives, leading to different outputs; therefore the model that is created depends on the problem to be faced. For example, let’s take into consideration
points that are close according to one representation may not be as close according to a different representation.
Learning from available data using statistical a priori models implies considering those data as a representative sample of their actual statistical distribution (for instance, assumed to be Gaussian). Unfortunately, that is seldom true. The more data we have, the better we can substitute a priori models with reliable a posteriori models built from data, often making no a priori assumptions at all. The fewer the data, the more robust the methods used to learn from them must be. Furthermore, we must be able to estimate how good our data-driven models are and make sure they can be generalized to other data of the same kind. As we said we need a set of data with which the model can be trained, but also a portion used to verify the correctness of the model; we can therefore distinguish three different sets of data:
there is in them and the better the model will work. There is no single absolute and perfect method, but there exist several methods with pros and cons. In general, it can be said that the less data available, the more robust the method must be both against the noise that can be contained within the data, and against overfitting. So one of the problems concerns the size of the dataset. Machine Learning “algorithm” The first step is to choose a representation of the data; some representations are more suitable for some problems than for others. Typically the representation is multidimensional, usually in the form of tables. It is also important to make a selection of the features to be used for the construction of the model: in fact, there are often many features available and not necessarily all of them are useful for the purposes you want to achieve. Since generally the complexity of a ML algorithm is proportional to the size of the dataset, it is often necessary to reduce it, by removing some features that are not useful to the model, or by merging two or more features into a single one if these are related to each other; at other times, however, it may be useful to create artificial features. So it is not necessarily true that a larger representation is better than a more concise one, but it depends on the problem. Furthermore, we would like to understand which are the regions of the representation domain in which the points tend to be most present, for each class. If the data are highly separable, the problem is easier and this leads to better solutions. The second phase involves the subdivision of the data into the 3 sets we have seen, that is training set, test set and, possibly, also validation set. Typically, most of the data is used for
Comparing a model’s performance on the training and on a test / validation set makes it possible to evaluate the degree of generalization of the learning process. Possible causes for which extremely different results are obtained on training set and test / validation set: ● the statistical distribution of the patterns in the two sets is not the same, i.e. the data do not represent the same thing, or they represent instances of the same problem that are very different from each other, or again, in the case of a classification problem, data of different classes are not present in similar quantities, which leads to better performance on classes with a lot of data, poor performance in poorly represented classes; ● the type of model is not appropriate; in particular, if the model is too simple, it is not even able to learn the data provided as input (underfitting); ● overfitting, the opposite case to the previous one: the model does not generalize, but limits itself to memorize the training data, with consequent excellent performances in the training phase and very bad ones in the test phase (validation); ● the data is too noisy and often too few to be able to remove it and obtain general data behavior. A model derived from the data is as good as the data from which it has been derived, so it is very important how we represent and divide the available data. Characteristics that a good dataset must have: ● large enough to describe all or most cases; ● correct, there should be as little noise as possible;
● consistent, there must be no contradictory examples, i.e. that lead to different results starting from the same data; ● well balanced: ○ for classification this means that all classes must be adequately represented, i.e. all with more or less the same amount of examples; if there are big differences, the model will tend to better recognize the classes with more examples and to make a lot of mistakes in those that are not (or poorly) represented; ○ for regression this means that all points must be uniformly distributed in the domain of the function to be approximated. The problem is that if you have “bad data” you cannot do much. So it’s very important that the examples are correct (i.e. contradictory or “wrong” examples must be avoided). This condition cannot always be satisfied. Actually, it is almost never satisfied. However, datasets that are good according to the criteria listed above can cope with this problem quite well. Sometimes noise, if not too high, can even be helpful, because it stimulates learning a regular, robust and generalizable behavior: it induces the learnt model to behave similarly within neighborhoods of the training examples, avoiding reproducing or memorizing faulty examples in the presence of outliers (i.e. overfitting).
In most cases, the problem can be mapped onto an optimization one, which involves finding a point in the search space (or domain) such that the value of a certain function measured in that point is minimized or maximized. If we consider a cost function or a loss function, this has to be minimized, because it measures the distance between our model and the ideal behavior; so the higher the loss, the worse the solution is. If, instead, we have a quality function, we want it to be maximized: we desire the quality of the solution as high as possible.
point xi that belongs to a certain cluster Ck is closer to its centroid xk than any other point that does not belong to it. Typically the centroid is calculated as the average of the coordinates of all the points of a data cloud (we can think of it as a “center of mass” of the point cloud). The quality of the clusters we obtain is strongly dependent on the representation of the data. If we think of data clustering as an optimization problem, we can see that it is a multi-objective optimization problem: ● we want to minimize the average distance of all the points in the cluster from its centroid, which means that the points have to be as close as possible to the centroid; ● we want to maximize the average distance of a centroid from all the other centroids (of other clusters), which means that the centroids of different clusters are as far as possible (the clusters are clearly distinguishable). From a topology point of view, we want to identify a set of non-overlapping regions Ck of the pattern space X (i.e. a so-called tessellation of the pattern space) each of which is the locus of all possible points that satisfy the definition of cluster given above. In order to identify the regions, we can separate each centroid to its “neighbors” with a line drawn at the mean distance between them. From a classification point of view, the main hypothesis is that d is an appropriate measure of similarity between data, which means that points that are close in the pattern space represent objects / concepts that are actually similar.
From the viewpoint of Artificial Intelligence (AI), learning is one of the properties of intelligent beings that AI aims to emulate. Regarding pattern recognition and classification, what is most interesting to AI researchers is the capacity of intelligent beings to recognize very different instances of a class, or corrupted / broken / partial instances. For example, the class of chairs can contain very different types of chair, not only the typical four-legged ones; furthermore, if we see only a part of a chair, because someone or something occludes it, we can still recognize it as a chair. In AI, methods that try to emulate the “flexibility” of intelligent beings (in recognizing objects, taking decisions, …) are usually referred to as Soft Computing methods. Since they exhibit abilities that are considered to be proper for intelligent beings, they are usually also referred to as Computational Intelligence methods (examples are Deep Learning, Fuzzy Logic, Evolutionary Computation, …). Most of them are directly inspired by natural phenomena; all of them can play a relevant role in Machine Learning.
We can obtain TP, FN, FP and TN rates normalizing the matrix, so dividing row-wise by Np and Nn. The following picture illustrates the main quality criteria for binary classifiers. One of the quality criteria that can be used is accuracy, which is the percentage of correct decisions out of all those that have been made. The problem arises when the number of positive and negative cases is not balanced: you can have high accuracy only because the classifier is "told" to produce the most likely output every time. For example we can think of a binary classifier that must distinguish the digit 0 from the other 9 digits; the probability of having 0 is 1 out of 10, while that of having a different digit is 9 out of 10. If the classifier always produces the negative case as an output, that is, for each digit that occurs it says that it is not zero, on average it will have successful in 9 out of 10 cases, i.e. with an accuracy of 90%; however the classifier is not working as it should, as it is not classifying between the two classes, but it is merely producing the most probable case. So accuracy must be taken carefully unless you use a very balanced dataset. We can extend the concept of Confusion Matrix (CM) also to an N-class classifier; in that case, the matrix will be NxN in size.
Properties: ● the CM associated with an ideal classifier is diagonal (i.e. the classifier always classifies correctly all the data / examples) ● the sum of all the elements of a row i is equal to the number of patterns belonging to the class i ● using the elements of each row it is possible to compute the quality indices for a binary classifier whose decision is “i / not i” ● TPi = Aii (equal to Recall if relative frequency is used) ● FNi = ∑j Aij (I - δij), where δij is the Kronecker delta (δij = 1 if i = j, else δij = 0)
In some cases, bad data may be available, leading to problems in evaluating the classifier: ● too few data; ● the data representing the different classes are not balanced, i.e. there are under-represented classes and over-represented classes; a class with multiple examples will be recognized much more easily than an underrepresented one. So it is necessary to balance the dataset, adding examples to those classes that have few or eliminating from those that have many; ● the data is not adequately distributed between the training and test sets; ● different error costs; ● there is noisy or erroneous data. A possible improvement that can be introduced is the stratification: both the training set and the test set (also the validation set, if used) are constructed in such a way as to have the same distribution, in order to make them balanced. However, if the data are few, it is often difficult to be able to divide them in such a way as to have both a sufficient number of data to train the model and to validate it; therefore, one could think of using all the available data for training the model and not leaving any for testing.