In recent years, Air Pollution has increased drastically and having worse effect of that on all the living beings. Majority of Countries in the world battling with increasing Air Pollution Levels. So, it has become a necessity to control and predict the Air Quality Index. In this research project, we will be implementing Data Mining and Machine Learning models to predict the AQI and Classify the AQI into buckets. For AQI prediction we have implemented five regression models Principal Component, Partial Least Square, Principal Component with Leave One Out CV, Partial Least Square with Leave One Out CV, Multiple regression AQI Data of Multiple Indian Cities. AQI Index further gets classified into 6 Different Categories called Buckets “Good, Satisfactory, Moderate, Poor, Very Poor and Severe” based on the value of the AQI. To predict the AQI bucket we have developed three classification models which are Multinomial Logistic Regression and K Nearest Neighbor and K Nearest Neighbors with repeat CV Classification algorithm. From the Air Quality Dataset of Different Indian Cities PLS model with Leave One Out Cross Validation was best at dimension reduction considering only the 5th component from all the models. In terms of accuracy PLS model was best with Lowest RMSE. From Station Wise Data of Indian Cities KNN Model with Repeated CV and Tune Length 10 performed best in terms of accuracy and AUC.
Keywords: AQI; KNN; MLR; PLS; PCR; AUC; RMSE; MAE; MAPE; ROC; Classification; Regression
Received: Oct 18, 2020 · Revised: Jan 7, 2021 · Accepted: Jan 28, 2021 · Published: 2021-05-25
Corresponding author: Mayuresh Londhe, [email protected]
This is an open access article under the CC BY 4.0 license.
How to cite: Mayuresh Londhe, "Data Mining and Machine Learning Approach for Air Quality Index Prediction," International Journal of Engineering and Applied Physics, vol. 1, no. 2, pp. 136–152, 2021.
As the globalization and industrialization era started the world witnessed radical lifestyle changes but as we progressed further, we encountered demerits of globalization and industrialization in terms of different types of pollutions. Out of various pollutions, Air pollution is the most hazardous and widely affected all over the globe. Researchers and Innovators are profoundly working towards finding different solutions to mitigate the hazard caused by poor air quality using prediction and monitoring methods. In 2018 European Parliament declared Breeze Technologies as the Most Promising Start-Up of the Year which focuses on monitoring Air Quality. If your paper is intended for a conference, please contact your conference editor concerning acceptable word processor formats for your particular conference.
Air pollution occurs when a combination of different hazardous gases and solid particles reaches a detrimental level. Major factors for this pollution are Industrial and Vehicle emissions. Global Warming, Acid Rains, Extinction of animal species and health problems are effects of Air Pollution. Particles that are as small as 0.01mm can cause illness and cardiovascular disease. Air Quality index is computed by measuring the level of different air pollutants such as PM2.5, PM10, CO, NO, NO2, SO2, O3 in the air.
Air Quality in the majority of Indian states and cities is proven to be unsafe. As a result, the count of cardiovascular diseases and chronic illnesses increased. Effectively the number of deaths due to Air pollution is 1.67 Million in the year 2019 out of 6.7 million deaths globally. In the list of most polluted cities in the world, 21 out of 30 were from India.
By predicting the Air Quality Index (AQI) using historical data could help to prevent deaths due to Air Pollution. This would assist government and environmental organizations to implement preventive measures.
This research paper is presented using the following template. First Section of the template provides an introduction of the research topic which focuses on highlighting the motivation behind the selection of the topic, present situation and research question. Section 2 elucidates related work, which mainly provides information regarding Literature presented by other researchers, Key results achieved by them, positive and Negative points of the research, Selection of models and methodologies their limitations. Section 3 provides a description of Data Mining Methodologies implemented in research. The fourth section describes models implemented and the evaluation of their results. Conclusion and future scope are the last section which is a summary of the research and further work that can be carried out to improvise and extend further.
In the paper [1], Multiple regression methods are applied to a dataset to predict the AQI for Delhi and Houston cities. Two different AQI scales were used to classify AQI values into 6 different groups. Mean Absolute Error (MAE), Mean Absolute Percentage Error (MAPE), Root Mean Square Error (RSME) performance evaluation methods used to evaluate the performance and accuracy of the model. Out of implemented models, multiple linear regression model with batch mini-batch gradient outperforms in terms of High Performance. The number of observations used for prediction is relatively low. Comparative studies can be done with respect to results obtained Multiple Linear regression model from paper [1] and the model implemented in this research paper.
In [2], Multinominal Logistics Regression (MLR), Decision Tree and K mean algorithm are examined sfor the prediction. Only a few important Pollutants were taken into consideration when implementing the model. AQI labels were divided into 3 categories Moderate, Good, and Unhealthy. Accuracy and Error of the model are predicted based on correct labeling of the data according to AQI levels. Out of all implemented models, MLR performed better than the Decision Tree model with an error rate of 0.442 and 0.666 respectively. Data Labeling, Data Splitting, Machine Learning, Process, Prediction Process were involved in model building. Here there is relatively less scope to compare the performance of Multinominal Logistic Regression with the model implemented in this paper as several AQI labels are not identical.
The work in paper [3], includes the requirement to build an Air Quality prediction model for the Northern Thailand region. Linear regression, neural networks, and genetic programming. algorithms were compared and analyzed. In the first model Data gathered from 12 different stations was averaged month-wise for the first five months of the Year and AQI was predicted for an entire month. In the second model, the data was split between Unhealthy Air and Unpolluted Air and forecasted station wise. Apart from Air Pollutants and AQI other environmental factors were involved in the analysis. Linear Regression performed well in comparison to the other two models with an accuracy of 97.78. Root Mean Square Error (RMSE) is adopted to calculate the effectiveness of the model.
[4] Here, an Accuracy of 98.67%, 97.78%, 98.67%, 94.22% and 99.56% was recorded for models K nearest neighbors (KNN), Support Vector Machine (SVM), Naïve Bayesian classifier, random forest and neural network respectively. Models were built using Preliminary Knowledge, Hardware Development, Data Gathering, Data Pre-Processing, Development and training of the model and Testing and Evaluation steps. Data was collected by privately owned multiple sensors after that data was preprocessed and labeled. Only 750 observations were taken into consideration. Here the source of the data is not a government or organization which could be a demerit as sensors used by a government agency could be more sophisticated in data gathering and sensing.
[5], In this different Auto Regression Models were implemented to predict the Air Quality Index (AQI) seven days prior. Hourly data of 11 days was further divided into 8 days of Training and 3 Days of Testing. Values used for P, D, Q while implementing the Arima model are not shared. Visualization of the time series, Stationaries the series, Plot Parameters, Build Model, make predictions were the steps involved. It was predicted with a Mean Square Error of 27.00. Only four pollutants and other atmospheric quantities were considered to predict Air Quality.
The author in [6], have used a different approach to Air Quality Prediction. The data of Pollutants concentrations and meteorological attributes were used separately. First Meteorological data was clustered using K means. Results from the clustering were then used to build a hybrid model. Results from the Hybrid model were compared with K Means, Support Vector Machine, Neural Network, Deep Leaning. The hybrid model proved to be better than all other models with respect to the error rate.
In the paper [7], Air Quality Indexes are computed and clustered using pollutants concentration amount. For each pollutant, there is a different scale used to decide the AQI and Respective Label. K means and Fuzzy C means algorithms were implemented for clustering the computed AQI into labels. In which Fuzzy C Means exhibited 100% accuracy which is better than K Means. Data was not split between training and test data due to which accuracies obtained casts doubt. We will be interested in analyzing the method used to compute the AQI from Pollutants concentration.
[8] AQI and Weather data of identical timeframe was merged to compare the relationship between the AQI values with Weather and to predict the AQI multiple regression models were implemented on merged data. Only RMSE was taken into consideration for evaluating the models. All the models were having RMSE in the close range between 40 to 44 except KNN with an RMSE of 58.
[9] Here, the source of the dataset is the same as one of the datasets used in the implementation of this research paper. There is a significant difference in approaches, in [9], Data of Delhi city for 31 Days from 37 different stations was collected. We will be interested in a comparison of the results of K nearest neighbor and Multinomial Logistic Regression with Support Vector Machine. Observations used in the approach are relatively less as the mean of the AQI was taken for 37 stations for 31 Days.
The dataset used in [10], is relatively large with fifty thousand observations also it was divided into a 70:30 ratio for training and testing. Light Gradient Boosting model performs better than Xtreme Gradient Boosting which is based on MSE Value.
Knowledge Discovery in Databases methodology is adopted for analyzing the databases. This is an iterative process defined by a sequence of steps. The primary objective of KDD methodology is to extract the hidden knowledge from the databases. The below Figure 1. represents the steps involved in KDD methodology.

We need to select the number of related datasets, three large datasets with more than 10000 rows and more than 10 columns related to AQI of Indian cities are selected. Air Quality Dataset of Different Indian Cities contains 16 columns which is a day-wise AQI of cities. Station Wise Data of Indian Cities contains 16 columns which is station wise data of each day for different states. Hourly Data of Indian Cities contains 11 columns, which is a station wise, Three days data of different cities.
The first step is selection. In which we have selected the Target Data from datasets. From the Air Quality Dataset of Different Indian Cities, we selected AQI Data of 13 Cities
Ahmedabad, Amritsar, Bengaluru, Chandigarh, Chennai, Delhi, Gurugram, Hyderabad, Jaipur, Kolkata, Lucknow, Mumbai, Vishakhapatnam. These are prominent cities in India where the majority of Urban and industrial activities take place. For Dataset two, we selected data of 2 stations from Andhra Pradesh State,6 stations from Bihar state, 5 Stations from Delhi state, 6 Stations from Maharashtra state. For the Hourly Data of Indian Cities, we have considered data of all the cities available.
Data pre-processing is the second step in KDD methodology. Data often contains noise, outliers and null values which could degrade the quality of analysis, due to which we need to handle noise, outliers and null values appropriately. AQI’s are computed based on values obtained from sensor devices which provides us the amount of pollutant present in the atmosphere. In rare situations, these sensor devices fail or they need to be serviced to obtain accurate results from the device. This failure of the device to sense the pollutant value results in null value computation of that pollutant for that period.
Below Figure 2. represents the number of null values in each column of the Air Quality Dataset of Different Indian Cities.

At First, we can see that AQI and AQI Bucket columns have 382 rows which indicate that all row doesn’t contain any record of pollutants due to which we will remove those 382 Rows from Air Quality Dataset of Different Indian Cities. Now we are remaining with pollutants columns, we will be using two different methods to impute the null values based on the number of missing values in the column. For columns that contain Null Values less than equal to 550, we will be using the fill function. As this is daily data, we are assuming that there won’t be a significant change in AQI of the Pollutant from Previous Day or One Day Ahead. The values will be imputed in both the direction which means first it will fill values in the down direction which will take the value of previous day to fill the missing value but if the previous day value is also null it will get imputed when there will be upward imputation which will take the value of one day after. Now we are left with Column PM10, NH3, Toluene, xylene. It won’t be appropriate to impute null values with a previous method when there are a greater number of missing values. We will be using the impute_lm function which will allow us to use a regression model to impute the missing values. Multiple linear regression is used for all the remaining columns, but independent variables are used depending on the type of pollutant.

Toluene ~ Benzene + O3+ SO2 + CO + NO + PM2.5 Xylene ~ Benzene + O3+ SO2 + CO + NO + PM2.5+ NO2

For Station Wise Data of Indian Cities, we first created 19 subsets of the dataset which contains data of respective stations and then they were merged using R bind function. Here we have used multiple methods to impute missing values i.e., removing insignificant columns, Mean value Imputation, mice imputation. Firstly, we removed Columns Xylene, Toluene and NH3 as missing counts are 11118,5189,4390 respectively. After this step for column PM2.5, we imputed the mean value of the column values in place of null values. Next, we applied the predictive mean matching method is used which helps reduce bias introduced during the imputation process by imputing real values from sampled data. We have kept the value m as 5 which is the default, maxit value to 3, as the number columns are more and it does require significant computation time. This will generate set of values for 8 variables. We selected Station Wise Data of Indian Cities computed by PMM to impute the Null values. Now we removed Station ID and Date Column to perform feature scaling before building a model. Below Figure 4. display the location of Missing Values in the dataset.
Hourly Data of Indian Cities contains concentrations of Pollutants which are in Âμg/m³. First of all, we need to convert these concentration values into AQI and then compute the AQI. This step is done in Microsoft Excel. AQI Calculator Excel was downloaded, using the formulas given in the document AQI values were computed for pollutants and then the Overall AQI value was computed by taking maximum value among all parameters for the particular instance of time. After this step Dataset was again imported in R software. The initial dataset was containing null values which were imputed using the fill function but the Dataset of AQI was having many instances where Pollutant AQI was Zero and Negative values were present. In ideal situations AQI value cannot be Zero or Negative so using abs() function in r we converted all negative values of numeric columns to positive values. After this, we converted all Zero values to Null Values and Imputed them using the fill function as this dataset contains data of Three days taken at unspecified time intervals.



having the majority of columns with numerical values there was little scope for data transformation. In all three Datasets, the Date column was in factors format. Using as. Date () function converted them in Date format. Hourly Data of Indian Cities contains row-wise information of pollutants unlike column-wise data of the other two datasets. It would be difficult to perform analysis on such a dataset, to convert the row-wise data of pollutants into column-wise we used the Spread function which takes the Key-Value pair as an argument. We passed Parameter and Value columns to the spread function which provided us five different columns of individual pollutants. Later this dataset was exported for AQI Conversion.
All the three Datasets were then randomly sampled into Training and Testing Datasets in a 75:25 ratio.


In this section, we will be discussing supervised learning algorithms used to build the model on a selected dataset. We will be looking at 3 Regression and 2 classification models.
In this Dataset, the dependent variable is Continuous type and all of the independent variables are also Continuous type that’s why we choose to implement Partial Least Square Regression Principal Component Regression. Both have significant similarities and differences. Both the techniques focus on dimension reduction while forecasting but Partial Least Square Regression is Supervised methodology while Principal Component Regression is Unsupervised methodology.
A. Principal Component Regression:
One of the Popular dimension reduction techniques Principal Component Analysis in which we extract a low dimensional set of features from a large number of attributes. This approach is used in Principal Component Regression as well. In this methodology, PCR focuses on deriving the first M Principal Components and after this process, it uses these components as the Independent Variable in linear regression model which is fit using least squares. The important point of discussion is the Optimal Value of M to consider during the Regression process, as the number of Components increases the Bias in the model decreases at the same time variance increases. Each obtained component in the process is a linear combination of all the original variables. One of the requirements of the PCR is to standardize each variable. Which brings all the variables on the same scale. It is essential because if the Variables are not standardizing the variables with Large Variance will have significant involvement in derived components. If all the variables are having the same unit, then it is not necessary to standardize the variables [11].
B. Partial Least Squares Regression:
In the previous methodology, we discussed the unsupervised approach to dimension reduction using PCR as the response variable Y is not considered while obtaining components. This becomes the Drawback for PCR as directions that is a good fit for predictor variables not necessarily be a good fit for predicting response. Partial Least Squares Regression uses a similar approach to dimension reduction, but it takes Predictor as well response variable in extracting components. Now we will look at how PLS computes the direction of the first component [11].
Here Z1 is the first direction
P is Standardize Predictors
φj1 is the coefficient from simple linear regression of Y and Xj
Xj is Original Predictor
Y is the Dependent /Response Variable.
Here the Highest weight is assigned to the predictor which is strongly related to the response variable.
To Find out the second direction of the PLS we first compute the residual between Z1. These residuals are information which the first direction couldn’t able to explain. Then we compute Z2 in the same way as Z1. This procedure is repeated M times and in the end this Z1, Z2,…..Zm, are then regressed to predict Y using Least Squares[11].
Tune Length: It is a number of levels used by each tuning parameter. In order to Tune the model automatically, we specify tune length. Which will generate the number of values of the response variable and out of that optimal value would be selected.
Leave one Out Cross-Validation: For resampling purpose, we have selected Leave one Out Cross-Validation. The advantage of using such a method is it considers all the training data for model building.
The dependent variable in Station Wise Data of Indian Cities is of categorical type. So, we have implemented two classification algorithms to predict the class of AQI. It is essential to classify the AQI indexes to correct categories as class names will be the easiest way for the layman to understand the Quality 
C. K Nearest Neighbour:
This is a classification algorithm that is supervised in nature. It classifies unlabelled data by using similar examples of data and their labels. This is implemented using a simple concept of Nearest Neighbour where for every record in the test data set. KNN identifies k records in nearly similar training data. The class of Majority k neighbours is then assigned to an unlabelled test record.

here D is the Training Data,
d is the Testing Data,
k is the number of records from D to select.
Step 1: Calculate the distance between d and Every record in D.
Step 2: Select k records from D which are nearest to d as per the calculated distance. This will create a subset of D; we call it P.
Step 3: Assign class of most frequently occurred label or Majority class label od P to d.
Here distances can be calculated in multiple ways such as Euclidian Distance, Manhattan Distance, Minkowski Distance and Hamming Distance. There are multiple rules to select the appropriate value of k, ideally, it lies between 3-10. One of the rules is to use k as the square root of the total number of observations. Results obtained can be well evaluated using Confusion Matrix, ROC Curve, AUC Value.

Confusion Matrix: This is a tabular representation of how the model has classified the class labels. This helps us evaluate the model on various aspects, such as Accuracy, Precision, Sensitivity, Specificity.
Roc Curve: This is used to depict the performance of the classification model at every level of classification. This plots the graph of Specificity vs Sensitivity. It not easy to interpret and compare the graphs that’s why we use AUC Value.
AUC Value: This is Area Under the Curve value, which ranges from 0 to 1. Here, we look for a value close to 1. For two different looking graphs the AUC Value could be similar.
D. Multinomial Logistic Regression:
This is an extension to the Binomial Logistic Regression where labels are Binary Categorical values such as 0 and 1, True and False. Multinomial Logistic Regression is used when the Dependent Variable is having multiple classes.

Here E(y) is the Probability of Logistic Regression, in which y could be coded as 0 or 1 when implementing Binary Logistic Regression, in the case of multiple regression it could take multiple values. The value of E(y) indicates the Probability that y=1 given a particular set of values for X1, X2, ……, Xp.

Here Left-Hand side is called Log-Odds, if there is a one-unit change in X1 there will be a change in log odds by β1 [12]. The results of the Logistic Regression will be evaluated by the Confusion Matrix.
E. Multiple Linear Regression:
This uses a similar approach of regression as Linear Regression only difference is the number of predictors used to build the model. Below is the Regression equation of Multiple Linear Regression.

Here, Y is a dependent Variable,
X1, X2, …..Xp are independent variables,
β0 is Y – Intercept (Constant Term)
β1, …,βp are regression (Slope) coefficients for each independent variable.
ε is the Error Term (Residuals).
In the above section, we looked at the 5 different models, now we will be looking at evaluation metrics used to evaluate and compare these model performances. There are numerous methods by which we can accomplish this. It is dependent on what type of model such as (Regression, Classification, Dimension Reduction) we have implemented. Some metrics are model specific as well.
A. Principal Component and Partial Least Squares Regression
As these Models are Regression type models along with dimension reduction feature, we have selected R Square, Root Mean Square Error (RMSE), Mean Absolute Error (MAE), Mean Absolute Percentage Error (MAPE), RMSEP (Root Mean Square Error of Prediction), % of Variability in predictor and Outcome Variable described by Number of Components.

Here we can see the percentage of variance explained by each component. X denotes the percentage of variability from predictors captured by each component and outcome denotes the percentage of variability from outcome variables captured by components. The decision to select the number of components is dependent on the goal of the analysis. Ideally, the component which is explaining more variability from both types of variables and Less number of components used to explain the variability. From Figure 12. we can interpret that model with 11 Components is an ideal choice, but the number of dimensions are not reduced, if we look at the 6th Component the which is explaining 78.45% and 89.19% variability in both Predictors and Outcome variables is a better selection as it explains optimal variability as well as significantly reduced the number of variables.



From Figure 12,13,14,15. we can say that the PLS Leave One Out Model is better at explaining the variability of both types of variables. If We compare the 5th component of all the models, PLS Leave One Out Model is explaining more variance than other models.
Now we will look at their prediction accuracy and Error Metrics.
RMSE: It is the root mean square between Actual Values and Predictions. It should be as low as possible. MAE: It is the mean absolute error between True and Actual Values. This also needs to be as low as

MAPE: This indicates to us that how accurately the model has done the prediction. Minimum MAPE value is desirable.
R Square: The amount of Variance of the dependent variable explained by independent variables is called as R Square. This should be close to 1, the higher the better [14].
From Figure 16. we can interpret that the PLS model has improved its accuracy in testing than training. The RMSE is reduced but MAE and MAPE value increased also there is an improvement in R Square value.


PCR model from Figure has also improved in testing which means that both PLS and PCR not overfitting the data. When compare them based on metrics mentioned above both the model seem to similar accuracy and error rate.

From Figure 18. we can see that RMSE and MAE values have increased in the testing phase which indicates that data is overfitted. In comparison to PLS with Leave One Out Cross-validation PLS and PCR models in Figure are performing better. PLS model has performed best when considering Accuracy as a measure.

B. K Nearest Neighbor and Multinomial Logistic Regression:
These two algorithms are classification algorithms therefore evaluation methods used here will be different. We have used Confusion Matrix, ROC Curve and AUC Value as evaluation methods.


Figure 20. ,21. represents the accuracy of KNN and KNN Repeated CV and Tune Length 10 with
respect to two Different K Values. Here, as the value of K is increasing accuracy is decreasing. Both models give the best accuracy at K=5. But we cannot compare both the models based on Figure as one of them is for Training Data and another one is for Test Data.



Figure 22. ,23,24. Provides us the details of how Models have classified data into each class. This is
important in evaluation as we can find out number of instances on which model has incorrectly predicted the class.


From Figure 21,26. we can find out that the model with repeated CV has improved from Training Data. After comparing two models the repeated CV model provided slightly better accuracy.


Sensitivity Starts to increase when it reaches 0.8 level, it remains constant and Specificity starts to decrease. Here AUC value of KNN with repeated CV is better in comparison. We are looking for AUC as high as possible which ranges from Zero to One.




Table 2. R Square Values for Multinomial Logistic Regression
There could be an argument over which R2 to consider as specified in Table 2. Looking at the R Square values from all three methods, we can say that the Logistic Regression Model is doing good in terms of class prediction. After comparing and evaluating all the classification models we can say that KNN with Repeated CV and Tune Length 10 has provided better accuracy and AUC.
C. Multiple Linear Regression

Multiple Linear Model here seems to be overfitting as the errors in the test evaluation has increased. Model is predicting with good R2 value which could be improved further. Initially 6 predictors were used for model building but after looking at Model Summary we found that two of the predictors are insignificant. We removed those variables and rerun the model but even after removing those variables model’s performance has not increased significantly.

From Figure 32. we can see that P values for SO2AQI and 03AQI are greater than 0.05. Value of R Square and Adjusted R Square are 0.7881 and 0.788 respectively.

Here we can see that after removing the insignificant variables ideally the values of R Square and Adjusted R Square should have increased but this not the case here.
In this research, we analyzed and evaluated Five different models on 3 different datasets. All the three datasets were related but they were using different nature, scale and approach for data representation. Due to which models applied on the particular dataset are only compared for evaluation. From the Air Quality Dataset of Different Indian Cities, we were looking to predict the quantitative AQI values along with dimension reduction techniques, in which the PLS model with Leave One Out Cross Validation was best at dimension reduction considering only 5th component from all the models. In terms of accuracy PLS model was best with Lowest RMSE. The objective of implementing models on Station Wise Data of Indian Cities was to correctly classify and predict the AQI Labels, in which the KNN Model with Repeated CV and Tune Length 10 performed best in terms of accuracy and AUC. The aim for Hourly Data of Indian Cities was to find significant factors that could lead to accurate AQI prediction from a range of Pollutants. Out of Six Pollutants, only Four were contributing significantly in model prediction.
The analysis and results obtained from this research encourage the possibility of further work, in order to improve the model’s performances and research goal.
The data analyzed in this research doesn’t include weather statistics. AQI values are also dependent on surrounding weather due to which inclusion of such data could lead to more precise AQI prediction. The data of AQI can be viewed as a Time Series, which leads to consideration of Time Series Algorithms for analysis.