# Automatic Classification of Web Images as UML Static Diagrams Using Machine Learning Techniques
## 6 Selection of Graphical Characteristics and Rule Induction by Machine Learning Techniques  
The discrimination of images representing UML static diagrams is achieved in this project by an automatic classifier that uses data mining techniques of supervised learning. Machine learning techniques are mechanisms used to obtain patterns through the analysis of data. This is a well-known subfield of computer science that evolved from the study of pattern recognition and computational learning theory in artificial intelligence, therefore we provide only a brief explanation. Machine learning explores the construction and study of algorithms that can learn from data, by building a model from example inputs in order to make data-driven predictions or decisions, rather than following strictly static program instructions [34]. On the other hand, Search-Based Software Engineering is  
Figure 10: Combination of two metrics using a combination of rectangular regions to discriminate between Positive (white) and Negative (black) classification. Figure 9: Combination of two metrics using a single (open) rectangle to discriminate between Positive (white) and Negative (black) classification. an approach in which search-based optimization is applied to software engineering [35]. Machine learning, then, is one of the techniques that can be used to perform search-based software engineering. Machine learning techniques can be supervised or unsupervised [36; 37]:  
* _Supervised learning:_ the algorithm is presented with example inputs and their desired outputs, and the goal is to learn a general function that maps inputs to outputs. * _Unsupervised learning:_ the inputs to the learning algorithm are given no output labels, leaving the algorithm on its own to find structure in the inputs. More specifically, supervised learning is the task of inferring a function from labeled training data, where each input is described by a vector of common attributes (see Figure 11). The training data consist of a set of training examples, each example consisting of an input object (in our case, the vector of graphical characteristics obtained from an image downloaded from the web) and a desired output value (in our case, the manual classification as a UML static diagram, or not, judged by the expert). The input attributes we have used in this project are:  
1. Number of gray tones. 2. Number of color hues. 3. Number of vertical/horizontal segments. 4. Number of vertical/horizontal segments at least 30 pixels long. 5. Number of horizontal segments at least 30 pixels long. 6. Number of vertical segments at least 30 pixels long. 7. Number of rectangles. 8. Number of main rectangles (not included in other rectangles). Note, we use the number of vertical/horizontal segments in four different ways, in order to increase their discriminatory power. A supervised learning algorithm analyzes the training data and infers a generalized function, which can be used for classifying new inputs. The effectiveness of the automatic classifier obtained is then measured against the testing set, which was previously segregated from the initial data, so that training and testing are performed with different datasets. In terms of search-based software engineering, the optimization problem consists in finding a function of the graphical characteristics (a piecewise function defined by a set of rules), such that it minimizes the distance with the experts' classification over the set of all images. This can receive the following mathematical formulation:  
* Let P be a set of images, or pictures, \(P=\left\{P_{1},\ \dots,P_{n}\right\}\). * Let C be the classifications over the set of pictures, \(C=\left\{c_{1},\dots,c_{n}\right\}\) such that \(c_{i}\in\left\{0,\ 1\right\}\) is the class provided by the experts to picture \(P_{i}\), where 0 represents \"not a static diagram\" and 1 represents \"a static diagram\". * Let G be a set of graphical characteristics obtained from pictures, \(G=\left\{g_{1},\dots,\ g_{k}\right\}\), such that \(g_{j}:P\rightarrow\mathbb{R}\ (1\leq j\leq k)\).