# Smart Cities Big Data Algorithms for Sensors Location
## 3 Process Implementation
### Algorithms for Classification and Training  
The goal of these algorithms is to classify data and each data acquisition, from the sensor a set of variables is identified as a record=(_n 1)( variable _i ), where n is the given number of variables of instrumentation, for example, light intensity, humidity, or movement. To get the registration form as register = \(|1|2||3||n|\) where each number is associated with a risk level of quality, as indicated by the standards. In our case of study, the record is formed by the variables register = CO, NO\({}_{2}\), O\({}_{3}\), PM\({}_{10}\), SO\({}_{3}\) to be classified according to the level of quality from the IMECA index.  
According to the results of Phase 3 of the process (see Figure 2), in Phase 4, the algorithms were executed--the algorithm to classify the sensor inputs, and the algorithm for training and setting the prediction model. Here, we proposed an architecture that allows each sensor to dispatch data captured to different processing threads, using cloud computing for a distributed performance, and with access to the shared memory. Figure 5 depicts the parallel processing of the data inputs captured by the sensors, their destinations in the cloud, and a matrix with frequencies, the shared memory variable to identify the hot-zones.  
Figure 4: Training results using machine learning applying the CART classification technique.  
Classifying the sensor's inputs can be made by a table in memory, in which the intervals for the variables are specified. In this case, a systematic review is carried out, starting with the values that exceed the limits in the IMECA classification. The best case is when just one comparison is needed, and the worst case is when the variable does not exceed any previous interval and must continue with the comparisons to the green level 1--see Figure 6.  
This classification can be optimized through CART reducing conditions, as can be observed in Figure 7. In this case, the number of variables is two (PM\({}_{10}\) and O\({}_{3}\))--the input lacks some variable values (i.e. CO, SO\({}_{2}\), or NO\({}_{2}\) variables) that are not necessary in this case for the classification.  
It is essential to highlight that, if a mathematical model presents a proper classification solution, for example, through the MLR model, that must be the less resource-consuming path to follow. Otherwise, as in this case, a classification method has to be selected. In any case, a matrix with the frequencies of sensors' events has to be updated. This update requires observing a time range. It is also necessary to label a representative sample of the big data burst, which will be used as a training group, maintaining the observation stored. The remaining registers are eliminated, avoiding the demand for storage space.  
Cloud storage occurs to form a temporary dataset for training, to take advantage of resources, and to distribute tasks for the tests with machine learning techniques. In the cloud, a process is activated when a sample size or a specific period is reached. The process consists of using the training data with the selected methods in Phase 3 of the process. In this example, SVM and CART run in parallel and are distributed concurrently. The algorithm finally updates the classification model to be read by the threads that will perform the classification.  
Figure 5: A general scheme of big data analysis with classification threads, an updated matrix with frequencies of pollution levels, and cloud training.