# An ML-Based Solution in the Transformation towards a Sustainable Smart City
## 3 Materials and Methods
### Computational Methods  
The first computational approach (named cascade of simple algorithms) includes several levels of analysis shown in Figure 3: from edge computing (close to the source, possibly AI-based, STAGE 1, algorithms 1-3 selected to suit the data) through data aggregation from particular segments (STAGE 2, algorithms 4-6 selected to suit the data) to central AI-based management at the level of the entire SSC (STAGE 3, algorithm 7 selected to suit the data). ML with a distributed, local approach to data collection and pre-analysis (edge computing) may provide a potential solution to various challenges regarding processing speed, data confidentiality and cybersecurity (Figure 3). Here, ML provides conditions in which multiple clients (data sources) jointly learn a model based on decentralised data sets. The algorithm numbers make orientation easier. Algorithms 1-7 are divided into three stages:  
* Stage 1 (algorithms 1-3): algorithms for edge processing;
* Stage 2 (algorithms 4-6): algorithms for data aggregation;
* Stage 3 (algorithm 7): global model algorithm. Each one of algorithms 1-7 was tested and selected for the data it was to analyse:  
* Algorithms 1-3: for segmented sensor data;
* Algorithms 4-6: for Stage 1 analysis data (to aggregate the segmented data);
* Algorithm 7: for Stage 2 (aggregated) analysis data. The whole procedure for constructing the model includes, in turn  
* selection of the overall structure of the cascade model (e.g., Figure 3: for 3 types of input sensors/data sets),
* selection of data sets (Table 2),
* selection of the best algorithms for STAGE 1 for the given data sets (Tables 3-5),
* selection of the best STAGE 2 algorithms for the data sets (Tables 6-8),
* selection of algorithms for STAGE 3 best for given data sets,
* completion and tuning of the overall model (e.g., Figure 4: for 3 types of input sensors/data sets). Figure 3: General architecture of AI-based management system (cascade of simple algorithms). This approach provides maximum flexibility for a cascade model based on simple, transparent algorithms, easy to increase the number and types of input data, and easy to learn and upgrade, e.g., as new, more efficient algorithms emerge. For greater readability of the models, the data used in the article are described in Section 3.2 Data sets and the algorithms used in the Results section. These data and models will allow cities and local managers to better understand the burden and geographic distribution of health, energy use and mobility/transportation variables in their jurisdictions and help them plan interventions in the above areas. This enables in-depth analysis and modelling of energy consumption behaviour and the discovery of complex factors influencing changes in the studied areas. The paper provides a framework for future work on integrating large data sets for analysis using machine learning techniques to integrate data from different sources occurring in SSCs. For the above-mentioned reasons, the study uses real data with naturally occurring distributions. The integration procedure includes preprocessing the data by checking the correctness and completeness of the data and their repeatability, possibly removing outliers or unreliable data (e.g., out of range), if necessary, also normalising the data, balancing them in classes and formatting them in the form of standard anonymised feature vectors/matrices (usually significantly shortened in relation to the raw data). Such a form of data is accepted by communication and data analysis systems, while improving network throughput and data security. Section 3 describes the use of seven algorithms selected in terms of criteria such as data prediction/classification accuracy and duration. This selection consists in applying a set of algorithms and searching for those that give the best results at each stage. Of course, in a real system, this process will take much less time due to previously established, repeatable data preprocessing procedures and the repeatable characteristics of device data.