Skip to Content
NitrogenNitrogen
  • Article
  • Open Access

10 November 2025

Air Pollution Forecasting Using Autoencoders: A Classification-Based Prediction of NO2, PM10, and SO2 Concentrations

,
,
,
,
and
1
Department of Computer Science Engineering, Algeciras Higher School of Engineering (ETSIA), University of Cádiz, 11202 Algeciras, Spain
2
Department of Industrial and Civil Engineering, Algeciras Higher School of Engineering (ETSIA), University of Cádiz, 11202 Algeciras, Spain
3
Department of Thermal Machines and Engines, Higher Technical School of Engineering of Algeciras (ETSIA), University of Cádiz, 11202 Algeciras, Spain
4
Engineering Institute, Campus da Penha, University of Algarve, 8005-139 Faro, Portugal

Abstract

This study aims to evaluate and compare the performance of Autoencoders (AEs) and Sparse Autoencoders (SAEs) in forecasting the next-hour concentration levels of various air pollutants—specifically NO2(t + 1), PM10(t + 1), and SO2(t + 1)—in the Bay of Algeciras, a highly complex region located in southern Spain. Hourly data related to air quality, meteorological conditions, and maritime traffic were collected from 2017 to 2019 across multiple monitoring stations distributed throughout the bay, enabling the analysis of diverse forecasting scenarios. The output variable was segmented into four distinct, non-overlapping quartiles (Q1–Q4) to capture different concentration ranges. AE models demonstrated greater accuracy in predicting moderate pollution levels (Q2 and Q3), whereas SAE models achieved comparable performance at the lower and upper extremes (Q1 and Q4). The results suggest that stacking AE layers with varying degrees of sparsity—culminating in a supervised output layer—can enhance the model’s ability to forecast pollutant concentration indices across all quartiles. Notably, Q4 predictions, representing peak concentrations, benefited from more complex SAE architectures, likely due to the increased difficulty associated with modelling extreme values.

1. Introduction

Air pollution forecasting has become a crucial environmental and public health issue worldwide. Urban and industrial regions face increasing challenges in predicting pollutant concentration dynamics due to complex emission sources and meteorological interactions. Among the various forecasting methods, deep learning (DL) models have shown promise for capturing the non-linear dependencies between variables across different geographic contexts [1,2,3]. The primary objective of this research is to predict future pollutant concentration levels in the Bay of Algeciras using machine learning techniques. In this complex zone, an important port is located with all the harbour and land operations that this entails. Numerous investigations have been conducted to evaluate the correlation between vessel data and air pollution in ports [4,5,6,7]. In the study [8] from August 2009 to March 2010, particulate matter (PM) was collected close to the container terminals in the port of Hong Kong, and results showed that ship emissions accounted for 7% of PM2.5 which supposed a 25% of the total mass. The authors in their study [9] analyse particulate matter emissions (PM10 and PM2.5) from a Mediterranean Sea port and find that emissions are significantly higher in the port than in the surrounding area. Emission sources include ships, port machinery, cargo handling, and vehicular traffic [10]. Ship emissions are identified as a significant source of PM2.5 in the port area [11]. The study developed by [12] measures nitrogen dioxide (NO2) in the air at six different locations within the port of Barcelona, (Spain) and correlated to with -term exposure with mental health. Results show higher NO2 levels inside the port, mainly due to emissions from ships and vehicles. Their findings suggested that short-term exposure to air pollution could have adverse effects on attention performance and perceived stress in adults. Eco-friendly ports prioritise environmental sustainability and economic advancement, endeavouring to minimise their carbon footprint and negative influence on the environment. This usually entails incorporating eco-friendly technologies, energy-efficient systems, and the utilisation of renewable energy sources [13,14]. The five primary focus areas of environmentally conscious port operations are hazardous waste management, air pollution control, water pollution control, noise pollution reduction, and energy efficiency. Developing an eco-friendly port that balances environmental concerns and economic necessities is a strategic objective for numerous ports. Additionally, another study evaluates the impact of shipping on air pollution in the port of Hamburg [15]. It finds that shipping emissions are a significant contributor to air pollution in the port, with particulate matter being the most problematic pollutant. The study emphasises the need to reduce shipping emissions for improving air quality in port cities [16]. The study presented by [14] developed a novel approach for forecasting marine traffic in ports for air pollution assessment purposes. The proposed method integrates the Automatic Identification System (AIS) data of historical vessel trajectories to predict future ship arrivals and departures. The approach was tested in the port of Livorno, Italy, and the results showed that the forecasted ship movements were accurate, and the method was able to provide reliable estimates of pollutant emissions from the ships. The authors suggested that this approach could be useful for developing proactive air quality management strategies in ports and for supporting decision-making processes aimed at reducing air pollution from maritime transport. In addition, some studies have used AIS data to analyse ship activity in a specific port [17,18,19] and assess its impact on air and water pollution. Other studies have used mathematical and statistical models to analyse the relationship between ship loading and pollution in ports [18,20]. Another study that discusses the various factors that can affect pollution in a port, making it difficult to make accurate and general predictions, is developed by [11]. The MED Ports conference on 28 April 2022, at the Algeciras Bay Port Authority focused on green ports. Shipping emissions in Europe have been analysed in previous studies [16,21], providing the basis for this research in the Bay of Algeciras, southern Spain. This area is the largest port in Andalusia and the fourth largest in Europe, handling over 100 million tons of goods annually since 2017. Its combination of industries, roads, and Gibraltar airport creates a complex air pollution scenario. This study continues previous work on air quality in the Bay, using sensor data and meteorological information [22,23]. Key variables identified in [22] are used to estimate hourly pollutant concentrations, while [24] compares classification models with ANNs for air quality prediction. Additionally, Ref. [23] analyses SO2 levels at two monitoring stations to assess the port’s influence. Numerous studies have employed Deep Learning (DL) methods to analyse air quality in various locations and situations [25,26,27,28,29,30,31,32]. A full review about air pollution modelling using deep learning is presented in [29]. Another study, Ref. [25], aimed to develop air pollution architectures using DL techniques for predicting future results. Spatiotemporal correlation was suggested in [26] by utilising stacked autoencoder (SAE) to obtain intrinsic features that could predict air quality in all stations simultaneously. The prediction accuracy of pollutant concentrations can be improved by combining Bidirectional Long Short-Term Memory (Bi-LSTM) with an autoencoder layer [27]. In Ref. [28], a comprehensive review of the application of deep learning to air quality forecast is presented, which includes various deep network architectures such as convolutional neural networks, recurrent neural networks, LSTM neural networks, and spatiotemporal deep networks. Furthermore, Ref. [33] developed an LSTM method to forecast air pollutants in the Bay of Algeciras. An autoencoder model was used in [31] to forecast pollution, which is an interesting application of deep Learning. DL is a subfield of machine learning that has gained significant attention in recent years from both academia and industry due to its ability to design alternative ways of learning the relationships between inputs and outputs through many connections [32,34,35]. There are very few studies that employ autoencoders in this field, and hence, one of the objectives is to evaluate the effectiveness of autoencoders for air pollution forecasting, particularly in this challenging scenario. Amongst them, we can find the research of [29,36,37]. There are several main reasons why predicting future values of these air pollutants can be important:
  • Health impact assessment: NO2, PM10 and SO2 are air pollutants that can have harmful effects on human health, particularly respiratory health. By predicting future levels of these pollutants, health authorities and policymakers can assess potential health impacts and take action to reduce exposure and mitigate risks.
  • Environmental monitoring: Predicting future levels can be an important part of environmental monitoring and management. By understanding how pollutant levels are likely to change over time, environmental managers can take action to reduce emissions and protect air quality.
  • Regulatory compliance: In many countries, there are regulations and standards for air quality that limit the levels of these air pollutants that are allowed. Predicting future levels of these pollutants can help ensure compliance with these regulations and avoid penalties or other consequences for non-compliance.
Despite the progress in machine learning for air quality forecasting, most existing studies rely on either traditional regression models or deep recurrent networks such as Long Short-Term Memory (LSTM), which primarily capture temporal dependencies but neglect latent spatial correlations among variables. Recent developments have demonstrated the strong potential of hybrid Deep Learning architectures (e.g., Autoencoders-Long Short-Term Memory (AE–LSTM), Convolutional Neural Network–Long Short-Term Memory (CNN–LSTM), Transformer-based models) to improve pollutant forecasting accuracy. Studies such as [1,2,3,37,38] highlight that autoencoders enable feature compression and denoising, while LSTM networks capture temporal dependencies. However, the combination or comparative performance of AE versus Sparse AE in port environments remains largely unexplored, which constitutes the main novelty of this work. Furthermore, few works focus on highly heterogeneous port–industrial regions, where emissions are influenced by both maritime and industrial sources [22,23,24,33]. This study contributes to filling this gap by applying and comparing Autoencoder (AE) and Sparse Autoencoder (SAE) architectures to model pollutant concentration quartiles, capturing intrinsic features from both meteorological and port activity data. This paper presents a deep learning approach for predicting air pollution using a stacked autoencoder (SAE) to create a spatiotemporal prediction framework that accounts for variable relationships in the dataset. The model predicts pollutant levels (NO2, PM10, and SO2) in Algeciras (Spain) and demonstrates prediction accuracy. An autoencoder is a neural network designed to reproduce its input at the output; when the hidden layer has fewer neurons than the input, it learns a compressed representation. The structure of a stacked autoencoder has been detailed in [39], where it was applied to air quality prediction, showing that predicted pollutant values closely follow observed patterns and align with the Air Quality Index (AQI) across multiple locations. Many pieces of research have been carried out by using a mathematical tool to find out the Air Quality Index (AQI) [40,41,42,43,44] which is very easy to understand and converts different air pollutants concentrations to a single number in an area. AQI combines many pollutants concentrations in some mathematical expressions to give a specific value for air quality. AQI is a solution to protect and prevent the public from air pollution health risk. The AQI provides comprehensive data of current air contaminants in a particular location. Based on AQI, an area can be categorised as good, satisfactory, moderately polluted, poor, very poor, and severe. There are significant differences in the AQI models developed across the various countries. The different countries adopt different concentrations of air quality parameters in the empirical equations of AQI models. Different Air Quality Indexes in several countries are presented in [45], explaining that the lack of synchronisation and standardisation of these indexes makes interpretation difficult. Different AQI models have been identified based on types and number of pollutants, their averaging time, standardisation function, and aggregation functions [44]. Nevertheless, also it is possible to use predictions of the pollution level of each air pollutant. The concentration levels are important to air quality studies because they report the actual concentrations of each air pollutant and their degree of pollution and effects. In the study by [41], the negative impacts in coastal areas of several harbour activities are mentioned considering the lower and higher level of concentrations of NO2, PM10, and SO2. These authors concluded that the highest concentrations of NO2 and PM10 were found in Europe while SO2 concentrations were considerably reduced due to their mitigation strategies adopted across Europe and emphasised that there is a lack of standardisation in order to compare AQIs in different locations.
This paper is structured into four sections: Introduction, Materials and Methods, Discussion, and Results.

2. Materials and Methods

2.1. Materials

This case study takes place in the Bay of Algeciras (Spain), located in the Strait of Gibraltar, an area with unique meteorological conditions and complex pollution due to chemical industries, the large port of Algeciras, and Gibraltar airport. The meteorological and pollutant data were provided by the Andalusian Government, which operates sixteen pollutant monitoring stations and five weather sensors (Figure 1), calibrated for capturing pollutant levels and atmospheric conditions. Additionally, vessel data in gross tons (GTs) were supplied by the Algeciras Bay Port Authority. The dataset includes meteorological measurements, various air pollutants, and vessel information, recorded hourly from 1 January 2017, to 31 December 2019, totalling 26,280 hourly records across 131 variables. The dataset spans from January 2017 to December 2019, which corresponds to the last period of uninterrupted and homogeneous data availability across all monitoring stations. Subsequent years include several data gaps due to equipment maintenance and disruptions during the COVID-19 pandemic, hence they were excluded to preserve temporal consistency. The initial phase involved data preprocessing, including standardisation and the imputation of missing values through ANN models, as successfully applied in previous studies [22]. Output variables (NO2, PM10, and SO2) were divided into quartiles (Q1–Q4) according to cumulative probability thresholds of 0.25, 0.5, and 0.75, defining the intervals [0–0.25), [0.25–0.5), [0.5–0.75), and [0.75–1]. Table 1 summarises all variables, their units, and the monitoring stations. A key variable in the dataset is vessel traffic, obtained from the Port Authority of Algeciras, which registers approximately 100,000 ships annually. This database was converted into a time series representing gross tonnage per hour (GT/h) and standardised with the rest of the variables. Air quality data from the Algeciras station were modelled using vessel traffic, meteorological parameters, and pollutant levels from 15 surrounding stations (see Table 1). The dataset was structured in an autoregressive format to predict pollutant concentrations at time (t + 1) from current conditions (t). Model performance was assessed through confusion matrices for the four-class problem (one per quartile). The 4 × 4 matrix (Table 2) was converted into a 2 × 2 matrix (Table 3) to compute accuracy, precision, sensitivity, and specificity (Equations (1)–(4)). Although a composite air quality index (AQI) could be derived from the predicted pollutant levels, separate models were retained to allow port authorities to apply targeted operational actions, such as adjusting ship locations, managing truck or road traffic, and mitigating pollution dispersion under specific meteorological conditions.
Figure 1. Location of the monitoring stations (m.s.). [1–16 pollutant m.s.; W1–W5 weather m.s.]. Source: Google Earth and authors’ own elaboration.
Table 1. Variables of the study and their monitoring stations.
Table 2. Multi-Class Confusion Matrix (C(i,j)).
Table 3. Equivalent Multi-Class Confusion Matrix.

2.2. Methods

2.2.1. Quality Measurements

In this study, the results obtained refer to the hourly concentration predictions (µg/m3) of NO2, PM10 and SO2, obtained from the AE/SAE models using as inputs meteorological variables (temperature, wind speed, humidity, etc.), vessel activity (gross tonnage per hour), and pollutant levels at surrounding monitoring stations.
A multiclass confusion matrix [46] was calculated as Table 2 and Table 3 show. Using this table, that contrasts predicted labels against true values, categorising the outcomes into True Positives (TP): Cases correctly classified as positive, False Positives (FP): Cases incorrectly classified as positive, True Negatives (TN): Cases correctly classified as negative and False Negatives (FN): Cases incorrectly classified as negative.
True-positive (TP) and true-negative (TN) results are correctly classified, while false-negative (FN) and false-positive (FP) results represent errors, as defined in the literature [47]. From this matrix, various evaluation metrics can be calculated, such as accuracy, recall (sensitivity), specificity, precision (see Equations (1)–(4)).
Accuracy: It measures the proportion of correct predictions over the total number of cases (Equation (1)).
A c c u r a c y = T P + T N T P + T N + F P + F N
Sensitivity/Recall: It measures the model’s ability to find all the true positives (Equation (2)).
S e n s i t i v i t y / R e c a l l = T P T P + F N
Precision: It indicates how many of the positive predictions are actually positive (Equation (3)).
P r e c i s i o n = T P T P + F P
Specificity: It evaluates how well the model identifies negative cases (Equation (4)).
S p e c i f i c i t y = T N T N + F P

2.2.2. Autoencoders

Autoencoders (AEs) are neural networks designed to replicate input data at the output with minimal distortion and play an important role in machine learning. They were first introduced in the 1980s by Hinton and the Parallel Distributed Processing (PDP) group [48], using the input data as “supervision”. AEs are a fundamental paradigm of unsupervised learning, where local synaptic changes can lead to coordinated global learning [49]. An AE consists of an encoder, which transforms the input into an internal representation, and a decoder, which reconstructs the original data from this representation. During training, the network adjusts its weights and biases to minimise the difference between the original and reconstructed data. The hidden layer produces the encoded data: if the number of hidden neurons (NH) is smaller than the input dimension (D), the code is compressed; if NH > D, a sparse representation is obtained [50,51]. The loss function E (Equation (5)) measures the reconstruction error, combining mean squared error, L2 regularisation Ω w e i g h t s , and sparsity regularisation Ω s p a r s i t y , with L2 helping to set the parameters λ and β [52].
E = 1 T t = 1 T j = 1 J x j t x ^ j t   2 + λ · Ω w e i g h t s + β · Ω s p a r s i t y
Ω w e i g h t s = 1 2 l = 1 L k = 1 t l i = 1 j l w k i ( l ) 2
Ω s p a r s i t y = i = 1 D ( 1 ) ρ · l o g ρ ρ ^ i + 1 ρ · l o g 1 ρ 1 ρ ^ i
The L2 regularisation term in Equation (6) sums the squared elements of the weight matrices for each layer, while the sparsity regulariser in Equation (7) encourages sparse representations in the hidden layer, with average neuron activation ρ ^ i and target ρ. Autoencoders (AEs) are unsupervised networks that replicate input at the output, learning an intermediate representation in a different dimensional space. This study compares Sparse Autoencoder (SAE) and AE performance, showing that SAE can extract specific features from the input, whereas AE cannot, though both reproduce the input at the output. Both networks were trained independently until the validation error reached a minimum. A stacked configuration with two autoencoder layers followed by a supervised layer was used to predict air pollutant concentration quartiles. Preprocessing included imputing missing values and normalising variables. Two autoencoders of dimensions NH1 and NH2 were trained and combined into a stacked AE (Figure 2), then used in testing with the supervised layer to predict the future signal (Figure 3).
Figure 2. Autoencoder/Sparse Autoencoder scheme. Training stage.
Figure 3. Autoencoder/Sparse Autoencoder scheme. Test stage.

2.2.3. Grid Search

Grid search is a hyperparameter optimisation method [53] that exhaustively evaluates models for all combinations within a predefined hyperparameter space. Since hyperparameters are set before training, the method systematically explores the grid until the best combination is found. It is most effective when the number of hyperparameters is below seven (M < 7) and the search limits are well defined. Although simple and effective, grid search can be computationally expensive [53].
Figure 4 illustrates movement within 1D, 2D, and 3D hyperparameter grids, where unevaluated neighbouring cells are explored to improve performance metrics such as MSE. Previously analysed cells were skipped, and to avoid local minimum, the process is repeated 20 times. Unlike conventional autoencoders used for dimensionality reduction, in this work, the stacked AE/SAE is configured to classify pollutant concentration quartiles, enabling the model to focus on distinct pollution intensity regimes. Furthermore, the grid search was tailored to optimise sparsity parameters jointly with layer size, which has not been previously applied in environmental forecasting models.
Figure 4. (ac). Grid search scheme 1D (a), 2D (b) and 3D (c). Illustration of the grid-search procedure in 1D (a), 2D (b), and 3D (c), where the search space expands from a line to a plane and a full 3D grid, and each point in the corresponding space is evaluated.

3. Results

A comparative analysis among multiple autoencoder architectures was carried out using a grid search–based experimental framework. For each configuration of NH1 and NH2 parameters, a confusion matrix was computed. The initial 4 × 4 multiclass matrix (Table 2) was converted into an equivalent 2 × 2 matrix (Table 3) to calculate standard classification metrics (sensitivity, specificity, accuracy, and precision) following Equations (1)–(4) for each quartile. This allowed an independent evaluation of classification performance per quartile; for instance, Q1 compared correctly and incorrectly classified samples against the remaining quartiles. The Euclidean distance from an ideal classifier (d1) was also obtained, and the entire experiment was repeated twenty times to ensure consistency. Statistical differences among model groups were analysed with Friedman and Bonferroni post hoc tests [54]. Mean SO2 values (Table 4) were derived using 2017–2018 data for training and 2019 for testing. A Multiple Linear Regression (MLR) model served as a baseline for comparison. Stacked autoencoder hyperparameters were optimised through grid search, including L 2 weight regularisation, sparsity constraints, and sparsity proportion. The first AE reduced the original 130-dimensional inputs to NH1 features, and the second compressed them to NH2, followed by a supervised layer that classified the NH2 vectors into four pollutant concentration categories (Q1–Q4). Overall, non-sparse models (5–75 neurons) provided better SO2 predictions, while a sparse 200-neuron configuration performed best for Q4, suggesting that higher concentration peaks require a more complex network.
Table 4. Classification outcomes for SO2 corresponding to each quartile prediction interval (Q1–Q4). NH1 = {50, 75, 200, 500} and NH2 = {5, 10, 50, 150}. In each quartile, the best-performing model has been highlighted in bold.
Table 5 presents the results in the case of PM10 and showed that in general, non- sparse configurations produced better predictions than sparse configurations of the AE stacker. Similarly to SO2, the prediction of the Q4 quartile is best performed with a sparse AE.
Table 5. Classification outcomes for PM10 corresponding to each quartile prediction interval (Q1–Q4). NH1 = {50, 75, 200, 500} and NH2 = {5, 10, 50, 150}. In each quartile, the best-performing model has been highlighted in bold.
Table 6 presents the results in the case of NO2 showing that in general, sparse configurations produced better predictions. It seems that NO2 is more difficult to predict and therefore, a more sparsity setting is needed. The results of the experimental procedure are presented in Table 4, Table 5 and Table 6, where the top-performing configurations for each class are highlighted in bold. In the tables, we have the best size of the second autoencoder model with each first autoencoder size. Then, the best of all is marked in bold, choosing the simplest of all those models that are not statistically significantly different from the results of the random resampling procedure of 20 replicates. These configurations were selected using a Bonferroni test with the d1 index, which measures the Euclidean distance to a perfect classifier. The models with the lowest d1 values are considered the best. The Friedman test, which is a non-parametric alternative to the Anova-test, was used to determine the statistical significance of the differences between the models. When several models show no statistically significant differences, the most parsimonious one is chosen according to Ockham’s razor principle. As shown in Table 4, for the Q1 quartile, a group of at least three models exhibited equivalent performance. Although the 500-neuron configuration achieved the highest index values, the simpler model with 75 neurons was ultimately selected as the optimal one. The research by [55] employed a hybrid deep learning-based method to predict PM10, achieving impressive results with a coefficient of determination value of 0.88 and a mean absolute error value of 7.24. On one hand, the authors in [56,57] determined that the best model among four neural network methods (Support Vector Machine (SVM), Gated Recurrent Units (GRUs), LSTM, Discrete Wavelet Transform (DWT-LSTM)) was the DWT-LSTM, which provided the highest prediction accuracy and lower errors (MAPE, MAE, RMSE) in all cases. On the other hand, Ref. [29] applied recurrent neural networks to forecast PM10 and SO2 concentration levels, obtaining a higher R value of 0.883 for SO2 compared to 0.673 for PM10. Deep Autoencoder (DAE) prediction models for PM2.5 and PM10 were utilised in [58] to determine the optimal settings for the DAE model in predicting PM10. A Stacked Autoencoder (SAE) architecture was employed in [29] to capture the intrinsic characteristics of air quality. Compared to traditional time series prediction models, the SAE model can simultaneously forecast air quality across all monitoring stations and demonstrates temporal consistency across all seasons. In [59], a hybrid model that combines the Variational Autoencoder (VAE) with the Generative Adversarial Network (GAN) was introduced to understand the dynamic spatial and temporal distribution of pollutants, resulting in accurate predictions. This implies that, in general, the use of autoencoders improves results, making it a cost-effective tool for large data-driven predictions. The research by [25] proposed a deep learning architecture and a SAE model to extract inherent air quality features. The study by [60] used SAE to predict PM10 concentrations in China. In [61], a deep convolutional autoencoder algorithm was applied to model the emissions of SO2 improving the obtained results using other methods and highlighting the benefits that deep learning can offer in estimating SO2 concentrations and pollutants emissions in general.
Table 6. Classification outcomes for NO2 corresponding to each quartile prediction interval (Q1–Q4). NH1 = {50, 75, 200, 500} and NH2 = {5, 10, 50, 150}. In each quartile, the best-performing model has been highlighted in bold.
The differences between Autoencoder (AE) and Sparse Autoencoder (SAE) in accuracy, sensitivity, precision, and specificity for each pollutant (SO2, PM10, NO2) will be visually shown using the best model in each case (see Figure 5a–c). This Figure compares the classification performance of Autoencoder (AE) and Sparse Autoencoder (SAE) models across pollutants. AE configurations generally achieve higher accuracy for moderate concentration levels (Q2–Q3), while SAE models perform slightly better at extreme quartiles (Q4), particularly for NO2. This suggests that sparse architectures may better capture the non-linear behaviour of pollutants at peak concentrations.
Figure 5. (a). Comparative Performance: AE vs. SAE for SO2. (b) Comparative Performance: AE vs. SAE for PM10. (c) Comparative Performance: AE vs. SAE for NO2.
The results in this manuscript indicate that the best performing models are those in general, in classes 1 and 4, with the highest concentration levels being in the fourth quartile (Q4). It is interesting to note that the non-sparse autoencoder (AE) configurations performed the best in quartiles Q1–Q3, while the sparse autoencoder (SAE) was the top performing model in quartile Q4. It is worth mentioning that if detailed results are needed in some cases, it may be necessary to obtain detailed results instead of a compressed representation of the data. This occurs in the case of Q4 quartile where peaks concentrations are collected. If a more accurate interpretation of the data is needed in some cases, a denser and more detailed representation of the input data may provide a more accurate interpretation of the data. This is the case for NO2 where, in all quartiles, a sparser configuration is necessary because good results are more difficult to achieve.

4. Discussion

The results of this study reveal meaningful insights into the effectiveness of Autoencoder-based models for forecasting pollutant concentration levels in a complex industrial and port environment such as the Bay of Algeciras. An examination of the confusion matrices revealed that most errors occur between adjacent quartiles (Q2–Q3), indicating that the model neither systematically overestimates nor underestimates pollutant levels. Misclassifications were slightly more frequent during summer months, coinciding with higher port activity and temperature inversions, which could suggest hidden exogenous factors (e.g., increased tourist traffic or wind-shadow accumulation zones). The comparison between traditional Autoencoders (AEs) and Sparse Autoencoders (SAEs) has shown that model performance is highly dependent on the pollutant type and its concentration level (quartile). For pollutants like SO2 and PM10, the non-sparse AE configurations provided slightly better performance across the lower quartiles of concentrations (Q1 to Q3), likely due to the AE’s capacity to compress information without sacrificing key data relationships. However, in the Q4 quartile, which corresponds to higher concentration peaks and likely, more irregular patterns, the sparse autoencoder (SAE) yielded superior results. This may be explained by the SAE’s capacity to learn more granular features and provide a more detailed internal representation of data where peak prediction requires a more complex structure.
Interestingly, for NO2, the SAE performed consistently better across all quartiles, suggesting that NO2 concentrations may be more volatile or dependent on non-linear and less obvious patterns within the data. The sparsity constraint likely allowed the model to better isolate meaningful patterns despite the noise. The classification–based evaluation using sensitivity, specificity, precision, and accuracy metrics confirmed that the selected configurations significantly outperform the benchmark MLR models across all pollutants and quartiles. Moreover, the Bonferroni and Friedman tests provided statistical validation for the selection of optimal model architectures, supporting the principle of model simplicity (Occam’s Razor) where multiple configurations yielded similar results. These findings align with previous studies using deep learning for air pollution prediction, such as those by [52,54], who demonstrated that DL models, particularly when tailored to the pollutant type, outperform classical methods. Our results further corroborate those observations while contributing a quartile-based evaluation, which provides a finer understanding of model behaviour at different pollutant concentration levels. In practical terms, these insights are especially valuable for real-time decision-making by environmental and port authorities. Depending on the concentration scenario (e.g., detecting peaks vs. monitoring baseline levels), different model configurations can be applied to balance computational cost and predictive detail. Moreover, as shown in this study, future improvements might be obtained by integrating hybrid architectures, such as SAE-LSTM models, to enhance temporal feature extraction and peak sensitivity. Although the present study focuses on the Bay of Algeciras, the proposed AE/SAE framework can be generalised to other port or industrial regions with similar multivariate data structures. By retraining the network with local meteorological and emission inputs, the model could be adapted to predict air quality in other coastal zones such as Rotterdam, Hamburg, or Singapore. This adaptability demonstrates the potential for scalable implementation in port environmental management systems.

5. Conclusions

The primary aim of this research is to develop predictions about future pollutant concentration levels in the Bay of Algeciras (Spain). This region is notably complex due to the presence of a major port, involving a multitude of harbour and land operations. To achieve the objective of this work, which is to predict pollutant levels by using deep learning techniques (AE and SAE), different configurations of the autoencoder have been tested considering different number of units in the two encoder layers. The performance of the models was evaluated considering sensitivity, specificity, accuracy, and precision, as well as the distance from an ideal classifier (1,1,1,1), applying both Bonferroni and Friedman post hoc statistical tests. These models were implemented using the hourly measurements of air pollutants (NO2, PM10, SO2) from the Algeciras monitoring station in southern Spain, together with meteorological and additional pollutant data collected throughout the Bay of Algeciras region. The forecasts of future pollutant levels were obtained under various hyperparameter configurations and using multiple stacked autoencoder architectures. The proposed approach achieved accurate predictions of pollutant concentrations, with the non-sparse AE models performing marginally better for lower concentration ranges (quartiles Q1–Q3), whereas the sparse autoencoder models yielded comparable accuracy for higher values (quartile Q4). In summary, a sparse configuration in an autoencoder may be preferable if detailed results are needed as occurs in the case of Q4 quartile concentrations prediction. Finally, predicting future values of SO2, PM10 and NO2 can be important for assessing health impacts, monitoring and managing the environment, ensuring regulatory compliance, optimising resource allocation, and understanding the potential impacts of climate change. Future work will be addressed in using LSTM networks or attention layers combined with AS/SAE to improve forecasting results. Moreover, future work will be carried out using newly collected data by deploying portable air quality sensors in the Bay of Algeciras to validate the model predictions in real time and to assess the model’s generalisation under unseen meteorological conditions.

Author Contributions

Conceptualization, M.I.R.-G., P.R.C.F., I.J.T. and P.J.S.C.; methodology, M.I.R.-G., M.d.C.R.R. and I.J.T.; software, M.I.R.-G., M.d.C.R.R. and I.J.T.; validation, M.I.R.-G. and P.J.S.C.; formal analysis, M.I.R.-G., M.G.C.-G., M.d.C.R.R. and I.J.T.; investigation, M.I.R.-G., M.G.C.-G., P.R.C.F. and M.d.C.R.R.; resources M.I.R.-G., P.R.C.F. and I.J.T.; data curation, M.I.R.-G., P.R.C.F. and M.G.C.-G.; writing—original draft preparation, M.I.R.-G. and I.J.T.; writing—review and editing, M.I.R.-G., P.J.S.C. and I.J.T.; visualisation, M.I.R.-G.; supervision P.J.S.C. and I.J.T.; project administration, P.J.S.C. and I.J.T.; funding acquisition, I.J.T. All authors have read and agreed to the published version of the manuscript.

Funding

This research received no external funding.

Data Availability Statement

The datasets presented in this article are not readily available because the data are part of an ongoing study.

Acknowledgments

This work is supported by “Plan Propio de la Universidad de Cádiz”. Data used in this work has been kindly provided by the Andalusian Regional Government and the Algeciras Bay Port Authority.

Conflicts of Interest

The authors declare no conflicts of interest.

References

  1. Bekkar, A.; Hssina, B.; Douzi, S.; Douzi, K. Air-pollution prediction in smart city, deep learning approach. J. Big Data 2021, 8, 161. [Google Scholar] [CrossRef]
  2. Agbehadji, I.E.; Obagbuwa, I.C. Systematic Review of Machine Learning and Deep Learning Techniques for Spatiotemporal Air Quality Prediction. Atmosphere 2024, 15, 1352. [Google Scholar] [CrossRef]
  3. Sun, H.; Fung, J.C.H.; Chen, Y.; Li, Z.; Yuan, D.; Chen, W.; Lu, X. Development of an LSTM broadcasting deep-learning framework for regional air pollution forecast improvement. Geosci. Model. Dev. 2022, 15, 8439–8452. [Google Scholar] [CrossRef]
  4. Corbett, J.J.; Winebrake, J.J.; Green, E.H.; Kasibhatla, P.; Eyring, V.; Lauer, A. Mortality from ship emissions: A global assessment. Environ. Sci. Technol. 2007, 41, 8512–8518. [Google Scholar] [CrossRef]
  5. Eyring, V.; Isaksen, I.S.A.; Berntsen, T.; Collins, W.J.; Corbett, J.J.; Endresen, Ø.; Grainger, R.G.; Moldanova, J.; Schlager, H.; Stevenson, D.S. Transport impacts on atmosphere and climate: Shipping. Atmos. Environ. 2010, 44, 4735–4771. [Google Scholar] [CrossRef]
  6. Olivié, D.J.L.; Cariolle, D.; Teyssèdre, H.; Salas, D.; Voldoire, A.; Clark, H.; Saint-Martin, D.; Michou, M.; Karcher, F.; Balkanski, Y.; et al. Modelling the climate impact of road transport, maritime shipping and aviation over the period 1860–2100 with an AOGCM. Atmos. Chem. Phys. 2012, 12, 1449–1480. [Google Scholar] [CrossRef]
  7. Holmes, C.D.; Prather, M.J.; Vinken, G.C.M. The climate impact of ship NOx emissions: An improved estimate accounting for plume chemistry. Atmos. Chem. Phys. 2014, 14, 6801–6812. [Google Scholar] [CrossRef]
  8. Yau, P.S.; Lee, S.C.; Cheng, Y.; Huang, Y.; Lai, S.C.; Xu, X.H. Contribution of ship emissions to the fine particulate in the community near an international port in Hong Kong. Atmos. Res. 2013, 124, 61–72. [Google Scholar] [CrossRef]
  9. Vukić, L.; Guidi, G.; Krämer, I. Air pollutant emission calculation and shipping costs: The case of yacht transport between the North Sea and Mediterranean ports. Mar. Policy 2023, 148, 105447. [Google Scholar] [CrossRef]
  10. Binkowski, F.S.; Roselle, S.J. Models-3 Community Multiscale Air Quality (CMAQ) model aerosol component. Model description. Environ. Sci. 2003, 108, 4183. [Google Scholar] [CrossRef]
  11. Mueller, D.; Uibel, S.; Takemura, M.; Klingelhoefer, D.; Groneberg, D.A. Ships, ports and particulate air pollution—An analysis of recent studies. J. Occup. Med. Toxicol. 2011, 6, 31. [Google Scholar] [CrossRef] [PubMed]
  12. Gignac, F.; Righi, V.; Toran, R.; Errandonea, L.P.; Rodney Ortiz, R.; Bas Mijling, B.; Naranjo, A.; Nieuwenhuijsen, M.; Creus, J.; Basagaña, X. Short-term NO2 exposure and cognitive and mental health: A panel study based on a citizen science project in Barcelona, Spain. Environ. Int. 2022, 164, 107284. [Google Scholar] [CrossRef] [PubMed]
  13. Lili, L.; Zhu, J.; Ye, G.; Feng, X. Development of Green Ports with the Con-sideration of Coastal Wave Energy. Sustainability 2018, 10, 4270. [Google Scholar] [CrossRef]
  14. Ystmark, K.; Seter, H. Reviewing tools and technologies for sustainable ports: Does research enable decision making in ports? Transp. Res. Part. D Transp. Environ. 2019, 72, 243–260. [Google Scholar]
  15. Ramacher, M.O.P.; Matthias, V.; Aulinger, A.; Quante, M.; Bieser, J.; Karl, M. Contributions of traffic and shipping emissions to city-scale NOx and PM2.5 exposures in Hamburg. Atmos. Environ. 2020, 237, 117674. [Google Scholar] [CrossRef]
  16. Tepe, A.M.; Doğan, G. Chemical characterization of PM2.5 and PM2.5–10 samples collected in urban site in Mediterranean coast of Turkey. Atmos. Pollut. Res. 2021, 12, 46–59. [Google Scholar] [CrossRef]
  17. Ceylan, B.O.; Akyar, D.A.; Celik, M.S. A novel FMEA approach for risk assessment of air pollution from ships. Mar. Policy 2023, 150, 105536. [Google Scholar] [CrossRef]
  18. Rapalis, P.; Šilas, G.; Žaglinskis, J. Ship Air Pollution Estimation by AIS Da-ta: Case Port of Klaipeda. J. Mar. Sci. Eng. 2022, 10, 1950. [Google Scholar] [CrossRef]
  19. Widyantara, I.M.O.; Hartawan, I.P.N.; Karyawati, A.A.I.N.E.; Er, N.I.; Artana, K.B. Automatic identification system-based trajectory clustering framework to identify vessel movement pattern. IAES Int. J. Artif. Intell. 2023, 12, 1–11. [Google Scholar] [CrossRef]
  20. Deniz Özkan, E.; Uzunoglu Kocer, U.; Nas, S. Statistical Analysis for Model-ling Ship Operation Processes in Ports. Sci. J. Marit. Univ. Szczec. 2020, 62, 71–79. [Google Scholar]
  21. Jalkanen, J.P.; Johansson, L.; Kalli, J. A comprehensive inventory of ship traffic exhaust emissions. J. Atmos. Chem. 2012, 69, 169–184. [Google Scholar]
  22. González-Enrique, J.; Ruiz-Aguilar, J.J.; Moscoso-López, J.A.; Urda, D.; Turias, I.J. A comparison of ranking filter methods applied to the estimation of NO2 concentrations in the Bay of Algeciras (Spain). Stoch. Environ. Res. Risk Assess. 2021, 35, 1999–2019. [Google Scholar] [CrossRef]
  23. Rodríguez-García, M.I.; Carrasco-García, M.G.; Ribeiro, M.d.C.R.; González-Enrique, J.; Ruiz-Aguilar, J.J.; Turias, I.J. Air Pollution PM10 Forecasting Maps in the Maritime Area of the Bay of Algeciras (Spain). J. Mar. Sci. Eng. 2024, 12, 397. [Google Scholar] [CrossRef]
  24. Rodríguez-García, M.I.; Ribeiro Rodrigues, M.C.; González-Enrique, J.; Ruiz-Aguilar, J.J.; Turias, I.J. Forecasting air pollutants using classification models: A case study in the Bay of Algeciras (Spain). Stoch. Environ. Res. Risk Assess. 2023, 37, 4359–4383. [Google Scholar] [CrossRef]
  25. Akin, Y.; Cansu, Z.; Oktay, H. Air Pollution Modelling with Deep Learning: A Review. Int. J. Environ. Pollut. Environ. Model. 2018, 1, 58–62. [Google Scholar]
  26. Li, X.; Peng, L.; Hu, Y.; Shao, J.; Chi, T. Deep learning architecture for air quality predictions. Environ. Sci. Pollut. Res. 2016, 23, 22408–22417. [Google Scholar] [CrossRef]
  27. Zhang, B.; Zhang, H.; Zhao, G.; Lian, J. Constructing a PM2.5 concentration prediction model by combining autoencoder with Bi-LSTM neural networks. Environ. Model. Softw. 2020, 124, 104600. [Google Scholar] [CrossRef]
  28. Liao, Q.; Zhu, M.; Wu, L.; Pan, X.; Tang, X.; Wang, Z. Deep Learning for Air Quality Forecasts: A Review. Curr. Pollut. Rep. 2020, 6, 399–409. [Google Scholar] [CrossRef]
  29. Xayasouk, T.; Lee, H.; Lee, G. Air Pollution Prediction Using Long Short-Term Memory (LSTM) and Deep Autoencoder (DAE) Models. Sustainability 2020, 12, 2570. [Google Scholar] [CrossRef]
  30. Arcucci, R.; Mottet, L.; Guo, Y.; Pain, C. Adversarial autoencoders and adversarial LSTM for improved forecasts of urban air pollution simulations. arXiv 2021, arXiv:2104.06297. [Google Scholar] [CrossRef]
  31. Mengara, A.G.; Park, E.; Jang, J.; Yoo, Y. Attention-Based Distributed Deep Learning Model for Air Quality Forecasting. Sustainability 2022, 14, 3269. [Google Scholar] [CrossRef]
  32. Hardini, M.; Heru, M.; Lena Magdalena, L.; Kenta, H.; Setiani, A.; Julianingsih, D. Image-based Air Quality Prediction using Convolutional Neural Networks and Machine Learning. Aptisi Trans. Technopreneurship 2023, 5, 109–123, Special Issue: Technopreneurship Driving Change in the Nation’s Future Leadership. [Google Scholar] [CrossRef]
  33. Rodríguez-García, M.I.; Carrasco-García, M.G.; González-Enrique, J.; Ruiz-Aguilar, J.J.; Turias, I.J. Long Short-Term Memory Approach for Short-Term Air Quality Forecasting in the Bay of Algeciras (Spain). Sustainability 2023, 15, 5089. [Google Scholar] [CrossRef]
  34. LeCun, Y.; Bengio, Y.; Hinton, G. Deep learning. Nature 2015, 521, 436–444. [Google Scholar] [CrossRef]
  35. Baldorj, B.; Tsagaan, M.; Sereeter, L.; Bulkhbai, A. Embedded Generative Air Pollution Model with Variational Autoencoder and Environmental Factor Effect in Ulaanbaatar City. Atmosphere 2022, 13, 71. [Google Scholar] [CrossRef]
  36. Rani Samal, K.K.; Sathya Babu, K.; Kumar Das, S. Temporal convolutional denoising autoencoder network for air pollution prediction with missing values. Urban. Clim. 2021, 38, 100872. [Google Scholar] [CrossRef]
  37. Wei, Y.; Jang-Jaccard, J.; Xu, W.; Sabrina, F.; Camtepe, S.; Boulic, M. LSTM-Autoencoder based Anomaly Detection for Indoor Air Quality Time Series Data. arXiv 2022, arXiv:2204.06701. [Google Scholar] [CrossRef]
  38. Mengara Mengara, A.G.; Kim, Y.; Yoo, Y.; Ahn, J. Distributed Deep Features Extraction Model for Air Quality Forecasting. Sustainability 2020, 12, 8014. [Google Scholar] [CrossRef]
  39. Xayasouk, T.; Lee, H. Air pollution prediction system using deep learning. WIT Trans. Ecol. Environ. 2018, 230, 71–79. [Google Scholar]
  40. Basir, N.I.; Tan, K.K.; Djarum, D.H.; Ahmad, Z.; Vo, D.-V.N.; Jie, Z. Autoencoder Artificial Neural Network Model for Air Pollution Index Prediction. IIUM Eng. J. 2025, 26, 1–21. [Google Scholar] [CrossRef]
  41. Sorte, S.; Rodrigues, V.; Borrego, C.; Monteiro, A. Impact of harbour activities on local air quality: A review. Environ. Pollut. 2020, 257, 113542. [Google Scholar] [CrossRef] [PubMed]
  42. Suman, M. Air quality indices: A review of methods to interpret air quality status. Mater. Today Proc. 2021, 34, 863–868. [Google Scholar] [CrossRef]
  43. Tan, X.; Han, L.; Zhang, X.; Zhou, W.; Li, W.; Qian, Y. A review of current air quality indexes and improvements under the multi-contaminant air pollution exposure. J. Environ. Manag. 2021, 279, 111681. [Google Scholar] [CrossRef]
  44. Kumar, P. A critical evaluation of air quality index models (1960–2021). Environ. Monit. Assess. 2022, 194, 324. [Google Scholar] [CrossRef]
  45. Plaia, A.; Ruggieri, M. Air quality indices: A review. Rev. Environ. Sci. Biotechnol. 2011, 10, 165–179. [Google Scholar] [CrossRef]
  46. Ting, K.M. Confusion matrix. In Encyclopedia of Machine Learning and Data Mining; Springer: Boston, MA, USA, 2010; p. 260. [Google Scholar]
  47. Rumelhart, D.E.; Hinton, G.E.; Williams, R.J. Learning representations by backpropagating errors. Nature 1986, 323, 533–536. [Google Scholar] [CrossRef]
  48. Baldi, P.; Lu, Z. Complex-valued autoencoders. Neural Netw. 2012, 33, 136–147. [Google Scholar] [CrossRef][Green Version]
  49. Makhzani, A.; Frey, B. k-Sparse autoencoders. In Proceedings of the 2nd International Conference on Learning Representations, ICLR Conference Track Proceedings, Banff, AB, Canada, 14–16 April 2014. [Google Scholar]
  50. Tino, P.; Benuskova, L.; Sperduti, A. Artificial neural network models. In Springer Handbook of Computational Intelligence; Springer: Berlin/Heidelberg, Germany, 2025; pp. 455–471. [Google Scholar]
  51. Kingma, D.P.; Welling, M. Auto-Encoding Variational Bayes. arXiv 2013, arXiv:1312.6114. [Google Scholar]
  52. Bergstra, J.; Bengio, Y. Random search for hyperparameter optimization. J. Mach. Learn. Res. 2012, 13, 281–305. [Google Scholar]
  53. Li, D.; Xiao, K.; Wang, X.; Guo, P.; Chen, Y. Towards sparse matrix operations: Graph database approach for power grid computation. Glob. Energy Interconnect. 2023, 6, 50–63. [Google Scholar] [CrossRef]
  54. Bland, J.M.; Altman, D.G. Multiple significance tests: The Bonferroni method. BMJ 1995, 310, 170. [Google Scholar] [CrossRef]
  55. Nasabpour, S.; Salajegheh, A.; Hassan Khosravi, H.; Nasiti, A.; Ranjbar, A. Prediction of hourly PM10 concentration through a hybrid deep learning-based method. Res. Sq. 2023. [Google Scholar] [CrossRef]
  56. Liu, B.; Zhang, L.; Wang, Q.; Chen, J. A Novel Method for Regional NO2 Concentration Prediction Using Discrete Wavelet Transform and an LSTM Network. Comput. Intell. Neurosci. 2021, 2021, 6631614. [Google Scholar] [CrossRef]
  57. Kurnaz, G.; Serhat, A. Prediction of SO2 and PM10 air pollutants using a deep learning-based recurrent neural network: Case of industrial city Sakarya. Urban. Clim. 2022, 41, 101051. [Google Scholar] [CrossRef]
  58. Yi, X.; Zhang, J.; Wang, Z.; Li, T.; Zheng, Y. Deep Distributed Fusion Network for Air Quality Prediction. In Proceedings of the 24th ACM SIGKDD International Conference on Knowledge Discovery & Data Mining (KDD ‘18). Association for Computing Machinery, New York, NY, USA, 19–23 August 2018; pp. 965–973. [Google Scholar] [CrossRef]
  59. Cheng, M.; Fang, F.; Navon, I.M.; Zheng, J.; Tang, X.; Zhu, J.; Christopher Pain, C. Spatio-Temporal Hourly and Daily Ozone Forecasting in China Using a Hybrid Machine Learning Model: Autoencoder and Generative Adversarial Networks. J. Adv. Model. Earth Syst. 2022, 14, e2021MS002806. [Google Scholar] [CrossRef]
  60. Liu, G.; Bao, H.; Han, B.A. Stacked Autoencoder-Based Deep Neural Network for Achieving Gearbox Fault Diagnosis. Math. Probl. Eng. 2018, 2018, 5105709. [Google Scholar] [CrossRef]
  61. Opio, R.; Mugume, I.; Nakatumba-Nabende, J.; Michael, S.; Mbogga, M.S. Modeling the atmospheric dispersion of SO2 from Mount Nyiragongo. J. Afr. Earth Sci. 2022, 197, 104771. [Google Scholar] [CrossRef]
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Article Metrics

Citations

Article Access Statistics

Multiple requests from the same IP address are counted as one view.