# IAQ Prediction in Apartments Using Machine Learning Techniques and Sensor Data
## 5 Discussion
The minimum percentage errors were MAPE = 1.57% (MLP2 for T), MAPE = 2.97% (MLP2 for RH), MAPE = 20.83% (RFR for CO\({}_{2}\)), MAPE = 0.66% (MLR for TVOC based on the SGP30 sensor), and MAPE = 0.41% (MLR for TVOC based on the SGP30 sensor). The minimum RMSEs of prediction were RMSE = 0.5 \({}^{\circ}\)C (MLR for T), RMSE = 1.8%RH  
Figure 11: Performance metrics for multiple linear regression (MLR) model testing on the data from the individual apartments, i.e., A1, A2, A3, A4, and A5. The metrics are (a) R\({}^{2}\)—no unit, (b) MAPE—in %, and (c) RMSE—in the units of air parameters: T (C), RH (%), CO\({}_{2}\) (ppm), SGP30 (s.r.u. ), and SGPC3 (s.r.u.). The respective values of the metrics are shown on the bars. (MLR for RH), RMSE = 174 ppm (KNN for CO\({}_{2}\)), RMSE = 106 s.r.u. (MLR for TVOC based on the SGP30 sensor), and RMSE = 106 s.r.u. (MLR for TVOC, based on the SGP30 sensor). Based on the fact that the best-quality models were linear ones (highest R\({}^{2}\)) and that they also offered the best prediction (lowest MAPE and RMSE), it could be claimed that the relationship between indoor air parameters in the living room and kitchen in the apartment is linear. This conclusion refers to a short-term perspective as the prediction was based on the data collected one minute before the prediction. Table 3 indicates the MLTs' performance regarding the naive approach by highlighting the performance metrics where MLTs outperformed the benchmark. As shown, in terms of median performance metrics, linear MLTs (MLR and MLP2) allowed us to build higher-quality models for all indoor air parameters except for CO\({}_{2}\) and TVOC based on the SGP30 sensor. The prediction errors made by linear MLTs were all lower than achievable using the naive approach. Additionally, as shown in Figure 10, linear models adequately captured and reproduced the temporal variability of indoor air parameters in the living room. The observed and predicted time series well matched each other in terms of timing of sudden increase or decrease as well as the magnitude of parameters change. These results justify applying linear MLTs for IAQ prediction in the considered framework by providing an added value compared to the naive approach. The fact that the results of the naive approach are very close to the results of the best MLTs suggests that the most recent results of measurements contribute greatly to an effective prediction. Still, the fact that the MLTs performed better than the naive approach in the framework of cross-suggests that the domination would increase when a prediction model is developed for a particular category of apartments, and even more so if the model was prepared for an individual apartment. Considering that five apartments were included in this study, the MLTs had to cope with a considerable diversity of object characteristics. It was associated with kitchen type (open or closed), the apartment ventilation system, the occupants' lifestyle and cooking habits, occupancy patterns, surroundings, etc. These multiple factors resulted in the diverse indoor conditions in the individual apartments. The results of their monitoring provided complex input data for MLT models, which ultimately influenced their performance. As displayed in Figure 11b,c, the most accurate prediction was attained in the case of apartments A1 and A4. Excluding CO\({}_{2}\), average MAPE was MAPE = 1.70 \(\pm\) 1.15% (for flats A1 and A4) and MAPE = 2.85 \(\pm\) 1.85% (for flats A2, A3, and A5). Based on Figure 11a, the R\({}^{2}\) of MLR was also highest when models were tested on the data from these apartments. Excluding CO\({}_{2}\), average R\({}^{2}\) was R\({}^{2}\) = 0.75 \(\pm\) 0.13 (for flats A1 and A4) and R\({}^{2}\) = 0.45 \(\pm\) 0.21 (for flats A2, A3, and A5). Common features of apartments A1 and A4, which made them distinct from the others, were that they were located in new apartments, fitted with an open kitchen and induction cooker.