# Data-Driven Approaches for Predicting and Forecasting Air Quality in Urban Areas
## 2 Materials and Methods
### Real-Time Prediction and Forecasting Application  
The Real-Time Prediction and Forecasting (RTPF) application aims to inform the public and authorities about the current _AQI_ and forecasted values for the next five days. This information enables timely measures to prevent adverse effects on the population. Implementing the RTPF involves addressing two key integration challenges:  
* The locally trained MA-AQI and AQIF models need to be hosted in the cloud to ensure they are accessible;
* A reliable data acquisition system must be established to use real-time data as inputs for the MA-AQI model. This involves collecting data from various sensors and devices and centralizing it within an IoT infrastructure. There are two primary approaches to achieve this: \(\bigcirc\) Data can be entered into a cloud-hosted database via API requests. This method facilitates data storage and retrieval while ensuring that the information remains up-to-date and accessible for analysis; \(\bigcirc\) Another solution involves employing an IoT hub service like Azure IoT Hub. This service platform connects IoT devices, enabling real-time data ingestion, management, and analysis. The RTPF application displays the collected data using the ASP:NET Web Application environment. It shows the current parameters along with the _AQI_ generated by the MA-AQI model. The predicted values from the AQIF model for the next five days are displayed in the application's graphical interface. Figure 8 depicts the conceptual diagram of the prediction and forecasting system process. The data are collected in real-time from multiple sources in the Bronx using an IoT infrastructure. The system utilizes models to predict and forecast AQ using the mentioned parameters. A detailed breakdown of the components and their interactions for the proposed IoT infrastructure is provided below. Figure 7: Conceptual Diagram of the AQIF. Data Collection Sources:
* Meteo Station. This component retrieves hourly data on weather parameters. The data are collected via an API when the cron job Cron_meteo runs hourly on the API. The result produced by the API is sent to the SQL Server Database hosted in Azure Cloud;
* AQ Station. AQ parameters such as CO, NO\({}_{2}\), SO\({}_{2}\), and PM\({}_{2.5}\) are gathered from the AQ monitoring station. These data are also transmitted via an API to the central database hourly when the Cron_AQ job is executed;
* Traffic Monitor. The number of vehicles is collected in real-time through an API and sent to the Azure SQL Server when the Cron_traffic hourly execution is released. 2. The central repository Azure SQL Server Database receives and stores all the data from the three primary sources (Meteo Station, AQ Station, and Traffic Monitor). The stored data include air pollutants, weather conditions, and traffic information, which the prediction and forecasting models then utilize. 3. The MA-\(AQI\) model's prediction receives the collected features (pollutant levels, weather data, and traffic counts) from the Azure SQL Database and predicts the \(AQI\) as the label. This is used to determine the current state of AQ based on the data inputs. 4. Forecasting Model AQIF forecasts the future \(AQI\) based on historical data series from the Azure SQL Database. It predicts the future \(AQI\) trend, potentially for proactive measures or alerts. 5. RTPF collects the predicted \(AQI\) from MA-AQI and the forecasted \(AQI\) from AQIF. This platform provides a real-time dashboard where users view the current and predicted AQ data on different devices (laptops, tablets, or mobile devices). The basic RTPF procedure includes the following stages:
* Data Integration. All collected environmental and traffic data are integrated into a central Azure SQL Server database for further processing;
* Real-Time Prediction. The system predicts current \(AQI\) based on real-time data using the MA-AQI model;
* Forecasting. The system forecasts future \(AQI\) trends using historical data. Figure 8: The conceptual diagram for the proposed IoT infrastructure.