1 Introduction

The convergence of building energy use, carbon emissions, fuel consumption, road traffic dynamics, and machine learning creates a complex nexus of issues and opportunities in modern civilization. Buildings and transportation are significant contributions to energy consumption and carbon emissions. Using machine learning algorithms to examine and enhance these elements provides a compelling path to reaching sustainability objectives. This study investigates the use of machine learning methodologies to address the complex interaction between building energy, fuel use, and road traffic, with the goal of developing solutions for a greener and more efficient future. The importance of connecting building energy systems with traffic on the roads is beneficial in the quest to reduce carbon emissions, boost energy efficiency, and create more functionally designed cities. Given the relationships between these systems, it is feasible to anticipate that the energy consumption of buildings will be optimized in accordance with the volume of traffic and that the use of renewable energy sources will become more efficient in place of fossil fuels. Additionally, by optimizing charging, this integration increases the uptake of electric vehicles and lowers greenhouse gas emissions in urban areas. The integration strategy leads to better urban design, more effective resource utilization, and a more robust energy distribution system. This method involves using Bayesian techniques to calibrate the model and machine learning algorithms to improve the accuracy of the calibration. The combination of these two techniques can help to reduce the uncertainty associated with building energy models and improve their predictive capabilities (Zhu et al. 2020). The model uses advanced evolutionary optimization techniques to improve its accuracy and has been evaluated by assessing thousands of retrofit variations of a case study building.. The model aims to provide a rapid and accurate estimation tool to be used in the energy efficiency optimization of complex and heterogeneous buildings. This approach can help decision-makers identify the most effective retrofit strategies and reduce the energy consumption of non-domestic buildings (Seyedzadeh et al. 2020). The study aimed to provide a reliable and accurate energy demand forecasting model to improve the energy efficiency of buildings for a sustainable economy. The results of the study can help facility managers improve the accuracy of their building’s long-term energy forecasts and identify the most effective energy efficiency measures (Luo et al. 2020). The use of machine learning algorithms in building controls has the potential to improve building performance and energy efficiency significantly. However, there are still challenges to be addressed, such as the need for large amounts of data and the complexity of the algorithms (Zhou and Zheng 2020). Accurate prediction of energy consumption can help building managers identify the most effective energy efficiency measures and reduce energy costs. Machine learning algorithms can be used to optimize building energy systems and reduce energy consumption without compromising occupant comfort. Predictive models developed using machine learning can be used to identify patterns and trends in energy consumption, which can help to inform policy decisions and improve energy efficiency at a larger scale (Pham et al. 2020). A holistic approach to urban planning that integrates transportation and building considerations is vital for enhancing energy efficiency.

By strategically locating buildings in proximity to well-connected roads and public transit hubs, cities can encourage sustainable transportation choices, minimizing the energy needed for commuting (Walker et al. 2020). Such research is essential for understanding variations and making informed decisions to promote environmentally friendly transportation options. Furthermore, the flexible grid-based electrolysis approach for hydrogen production, specifically for fuel cell vehicles, offers a promising avenue to decrease expenses and curb greenhouse gas emissions. Integrating renewable energy sources into the electrolysis process optimizes hydrogen generation, enhancing cost-effectiveness while reducing the environmental footprint. Finally, a concerted effort involving technology, policy, and public awareness is crucial to achieving carbon emissions reduction and improved fuel efficiency on a global scale. Integrating innovative technologies, such as machine learning and renewable energy, and addressing regulatory and infrastructure challenges are essential steps toward a greener and more sustainable future.

In summary, these classifiers are all supervised learning algorithms that make predictions based on labeled data. Random forest and AdaBoost are ensemble learning methods that combine multiple models to make predictions. At the same time, KNN and decision tree algorithms rely on nearest neighbors or recursive splits to classify new data points.

The main contributions to the research work.

  • Poor air quality from traffic emissions necessitates enhanced filtration in HVAC systems, increasing energy consumption for ventilation and air purification within buildings.

  • Piezoelectric materials embedded in roadways can convert vehicle-induced vibrations into electricity, potentially powering nearby buildings and street lighting.

  • Higher traffic volumes and noise levels require better building insulation, adding to energy demands for heating and cooling to maintain a comfortable indoor environment.

  • Vibrations caused by heavy traffic can impact the structural integrity of buildings, potentially requiring additional energy for structural reinforcements and maintenance.

Traffic emissions necessitate improved HVAC filtration to mitigate poor air quality, amplifying energy consumption for effective building ventilation and air purification. Balancing this with sustainability goals is essential to minimize environmental impact while maintaining indoor air quality. Embedding piezoelectric materials in roadways allows for converting vehicle-induced vibrations into electricity. This innovative approach holds the potential to power nearby buildings and street lighting, enhancing sustainability in urban environments. Elevated traffic and noise levels mandate enhanced building insulation to sustain a cozy indoor atmosphere. However, this leads to escalated energy requisites for heating and cooling systems, posing a dual challenge of comfort maintenance and energy efficiency in today’s urban landscape. Balancing both is vital for sustainable, comfortable living spaces. Heavy traffic vibrations can jeopardize building structural integrity, necessitating extra energy for reinforcement and maintenance. This dual concern underscores the need for balanced urban development, integrating structural stability with energy-efficient strategies to ensure sustainable, resilient cities.

The rest of the sections are Related Work, Methods and Materials, Results and Discussions, Intelligent Routing System, Conclusion and References.

1.1 Novelty of the research work

The introduction of the SGDo-HP-LR-GP framework represents a groundbreaking innovation, merging advanced optimization methods with Lasso Regression and geographical mapping. This integration revolutionizes the Intelligent Emergency Routing Response System (IERRS) for road traffic trajectories, offering a holistic approach to traffic analysis and safety. Real-time data collection, stochastic optimization, and geographical mapping combine to provide a multidimensional view of traffic behavior, enabling the identification of bottlenecks and emergency routes. The research work innovatively integrates road network design with building energy use, emphasizing efficiency. Efficient road systems minimize travel distances, reducing fuel consumption and building energy needs. Strategic urban planning, aligning transportation and buildings, optimizes sustainability, highlighting the vital link between road traffic and energy-efficient urban development. Piezoelectric materials integrated into roadways harness mechanical pressure from passing vehicles to generate electricity, contributing to sustainable energy production. This innovation transforms road vibrations into a renewable power source, enhancing the efficiency of urban infrastructure while promoting eco-friendly energy solutions.

1.2 Why the integration in the proposed model

The integration of five intelligent models of our proposed model, namely XGBoost, SGDo, HP, LR, GP and PF, in the development of the proposed SGDo-HP-LR-GP model fills the need for very accurate road traffic trajectory prediction in the IERRS system. XGBoost gives good accuracy in predictions, while the Stochastic Gradient Descent Optimizer avails itself in the right optimization of model parameters. Hyperparameter tuning increases efficiency and is followed by Lasso Regression, which helps in the selection of features and reduces overfitting. Geographical Mapping places the forecast into a geographical perspective, and polynomial features give rise to accuracy, which refines the usefulness of the system, especially in actual operations. This particular synergy utilizes a wide range of strengths unrelated to one another to increase the chances of high success rates in predicting the best emergency routing responses while being time-sensitive.

2 Related work

Researchers have developed a high-density piezoelectric energy harvesting system that can generate energy from highway traffic. The system can reach an energy density as high as 15.37 J/(m.pass.lane) based on laboratory evaluations and road tests. The project team took an integrated multi-disciplinary approach involving mechanical, electrical, engineering, civil, and automobile engineering, material science, and physics to develop technologies for harvesting high-density piezoelectric energy (Chen et al. 2021). An equivalent circuit model of the stacked piezoelectric transducer that considers loss impedance to optimize the output electrical energy of a piezoelectric monitoring system under traffic load. The authors also consider the spatial arrangement of the piezoelectric transducers to optimize the output (Wang et al. 2022a). The authors propose a structure optimization method for piezoelectric energy harvesters that can improve the power generation effect of the road. The proposed system can help enhance the efficiency of piezoelectric energy harvesting systems and promote their application in road infrastructure (Wang et al. 2022b). The authors propose a structure optimization method for piezoelectric energy harvesters that can improve the power generation effect of the road. The proposed system can help enhance the efficiency of piezoelectric energy harvesting systems and promote their application in road infrastructure. The study highlights the importance of considering the traffic environment applicability of piezoelectric energy harvesting devices to optimize their performance (Wang et al. 2021).

The authors found that the piezoelectric flooring tiles can generate electricity from the footsteps of commuters and can be used to power lighting and other electrical devices in the station. The study highlights the potential of piezoelectric energy harvesting systems to generate electricity in public buildings and reduce their reliance on the grid (Moussa et al. 2022). The system is optimized to generate electricity from solar energy and foot traffic. The authors also incorporate machine learning forecasting to optimize the system’s performance. The proposed system can help enhance the efficiency of smart buildings and promote sustainable energy use (Mukilan et al. 2023). Piezoelectric materials can be integrated into building structures, such as floors, walls, and roofs, to generate electricity from mechanical vibrations caused by human activities, wind, and other sources. It can also be used for self-sustained smart sensing in buildings, such as structural health monitoring, occupancy detection, and indoor air quality monitoring (Chen et al. 2019). In the automotive domain, an innovative approach combining active steering control (ASC) and direct yaw control (DYC) has been introduced to improve lane-following performance, especially in challenging road conditions. Simulation results validate the practicality and efficiency of these strategies, particularly when tire-ground adhesion and road curvature are unpredictable (Yang et al. 2019).

Moving to network traffic analysis, researchers have proposed trajectory-based methods that convert individual trajectory data into evolving graphs to analyze network-wide traffic patterns (Kontorinaki et al. 2019) (Kim et al. 2022). A dataset of city-scale vehicular continuous trajectories known as holographic traffic data has also been developed to reproduce comprehensive traffic dynamics (Wang et al. 2023). Traffic trajectory extraction, prediction, clustering, classification, anomaly detection, reconstruction, and generation are active research areas. Innovative techniques using deep learning, attention mechanisms, generative adversarial networks, and more promise to enhance our understanding of traffic behavior and improve traffic management (Liu et al. 2023; Luo et al. 2023; Ding et al. 2020; Prasanth et al. 2022; Zhao and Shi 2019; Rahman and Hasan 2022; Banifakhr and Sadeghi 2021; Balado et al. 2020; Zhang et al. 2021; Jarry et al. 2021).

In conclusion, these research endeavors represent a glimpse into the exciting developments across various fields, from robotics and traffic management to IoT and machine learning. As these innovations continue to evolve, they hold the potential to shape a safer, more efficient, and interconnected future.

2.1 Research gap

The previous studies investigate how to increase the reliability of building energy simulation and discuss the possibilities of using piezoelectric materials to generate electricity; there is room for advancement. It is rather surprising that these two spheres are not interconnected. Previous papers have yet to discuss how to pursue the integration of real-time traffic data, affected by geometric characteristics and weather etc., with the building energy management systems (BEMS). This integration brings out the possibility of a system that is able to take a more holistic look at the energies used in a particular building and the effectiveness of methods that can be implemented to minimize waste.

3 Methods and materials

Machine learning is a field of computer science that develops algorithms and models that enable computers to learn from data and make predictions or decisions based on that data. Here are some key concepts in machine learning:

3.1 Piezoelectric materials for highway energy harvesting opportunities and threats

An application discussed is the tapping of energy from highway traffic utilizing high-density piezoelectric materials.

3.1.1 Types and properties of piezoelectric materials

Ceramics: This includes lead zirconate titanate (PZT) and barium titanate (BaTiO3) that have high piezoelectric coefficients (a measure of the material’s ability to convert mechanical stress to electricity). Thus, while they remain valuable materials they can be somewhat brittle and also prone to the detrimental effects of their environment.

Polymers: Polyvinylidene fluoride (PVDF) is another example of this type; it is more flexible and provides better performance in severe working conditions. However, translated their piezoelectric coefficients are generally lower than ceramics.

Composites: It is also found that scientists are working on the idea of integrating ceramics and polymers where the corresponding material will have considerable flexibility as well as good energy conversion.

3.2 Practical challenges of integrating piezoelectric materials in roads

Durability and wear: These bare areas go through a lot of stress, heavy weights and weather conditions. Piezoelectric materials must be able to endure these conditions for long periods without considerable change in their characteristics.

Cost-effectiveness: At the moment sometimes the piezoelectric materials and fixing them can be rather costly. This has to be accompanied by the considerable energy generation capacity in the future to make the technology economically profitable.

Efficiency optimization: The next step is to identify the correspondence between the characteristics of the given traffic flow and vehicle type on the one hand and the precise location and design of piezoelectric members as a part of the road pavement on the other.

Maintenance and repair: It can be seen that the inclusion of piezoelectric materials complicates road design. Solutions for easy and cheap standards of maintenance and repair should be provided.

Environmental impact: The various phases in the piezoelectric material’s life cycle, from extraction of the required raw material to actual processing and final disposal, must be closely managed from the environmental point of view.

3.3 Basic machine learning concepts

Supervised and unsupervised learning are two fundamental paradigms within machine learning, each with distinct characteristics and applications. As the name suggests, supervised learning relies on labeled data with known correct answers during the training process. This labeled data serves as a teacher guiding the model to learn patterns and relationships between input features and corresponding target labels. The model then generalizes from this training to make predictions on new, unlabeled data. It’s widely used in image classification, sentiment analysis, and speech recognition tasks.

The architecture flow diagram in Fig. 1 shows how the initial dataset is preprocessed before being transmitted to the models, including the proposed model. Although the other models produce superior outcomes, the proposed model yields the best outcome, as can be shown in Tables 1, 2 and 3. For the Intelligent Emergency Routing Response System (IERRS) to deliver optimum routing that reduces carbon emissions and fuel consumption to the cars, the Enhanced Interior Gateway Routing Protocol (EIGRP) was implemented.

Fig. 1
figure 1

Architectural flow diagram

Table 1 Comparison of other models with the proposed model
Table 2 Epochs with metrics for different models
Table 3 Batch size versus other models

3.4 Feature extraction

Feature extraction is vital in machine learning, enhancing models by choosing essential features through stats, domain expertise, or automated methods, reducing dimensionality, and improving pattern recognition.

3.5 Model evaluation

Model evaluation is essential to determine how well a machine learning model performs. Various metrics, such as accuracy, precision, recall, and F1 score, help assess a model’s performance. Choosing the right metric depends on the specific task and the balance between precision and recall required.

3.6 Overfitting

Overfitting is a common pitfall in machine learning where a model becomes too complex and starts capturing noise in the training data rather than genuine patterns. Regularization and cross-validation mitigate overfitting and ensure the model generalizes well to new data.

3.7 Random forest

Random forest is an ensemble learning algorithm that combines multiple decision trees to make predictions. By aggregating the results of individual trees, it improves accuracy and reduces overfitting. Random forest is a powerful choice for classification and regression tasks.

3.8 Decision tree

Decision trees are tree-like structures where each node represents a condition or feature, and each branch corresponds to a possible outcome. Decision tree algorithms recursively select the best feature to split the data, making them interpretable and useful for classification and regression.

3.9 AdaBoost

AdaBoost is another ensemble learning method that combines multiple weak classifiers to create a strong classifier. It iteratively assigns higher weight to misclassified samples, forcing the model to focus on the challenging instances, thus improving overall performance.

3.10 K nearest neighbors (KNN):

KNN is a simple but effective classification and regression algorithm. It relies on the proximity of data points in feature space to make predictions. It’s a non-parametric method, meaning it doesn’t assume specific data distributions and can adapt to various data types.

3.11 Stochastic gradient descent optimizer

Stochastic gradient descent (SGD) is an optimization algorithm that trains machine learning models. It updates model parameters iteratively, using small random subsets of the data (mini-batches), making it efficient for large datasets and deep learning models.

3.12 Hyperparameters

Hyperparameters are settings that control the learning process but are not learned from the data itself. These include learning rates, regularization strengths, and the number of hidden layers in a neural network. Choosing appropriate hyperparameters is crucial for achieving optimal model performance.

3.13 Lasso regression

Lasso regression is a variation of linear regression that introduces L1 regularization, which encourages the model to use fewer features and results in a sparser and more interpretable model. It’s particularly useful when dealing with high-dimensional data.

3.14 Geographical mapping

Geographical mapping involves creating visual representations of the Earth’s surface. It requires collecting geographical data and presenting it in various forms, such as maps, charts, and graphs. Geographical mapping is essential in cartography, geographic information systems (GIS), urban planning, and environmental science.

Figure 2 shows the construction of the proposed model using SGDo-HP-LR-GP, which combines XGBoost, stochastic gradient descent optimizer (SGDo), Hyperparameters (HP), lasso regression (LR), geographical mapping (GP) and polynomial features (PF) to enhance prediction accuracy.

Fig. 2
figure 2

Construction of the proposed model

$$\text{F}(\text{x}) =\Sigma (\text{leaf value }*\text{ indicator function}(\text{leaf}))$$
(1)

F(x): The decision tree output for input x.

leaf value: The value assigned to a specific leaf node in the decision tree.

Indicator function(leaf): A function that returns 1 if x falls into the corresponding leaf and 0 otherwise.

$$\text{RF}\left(\text{x}\right)=\Sigma {\text{F}}_{\text{k }}(\text{x})$$
(2)

RF(x): The output of the Random Forest for input x.

\({\text{F}}_{\text{k }}(\text{x})\): The output of the kth decision tree in the Random Forest.

$$\text{Gini}\left(\text{p}\right)= 1 -\Sigma ({{\text{P}}_{\text{i}}}^{2 })$$
(3)

Gini(p): Gini impurity for a particular node.

Pi: The probability of class I in the node.

$$\text{Entropy}\left(\text{p}\right)= -\Sigma ( {\text{p}}_{\text{i}}*{\text{log}}_{2}{(p}_{i})$$
(4)

Entropy(p): Entropy for a particular node.

Pi: The probability of class i in the node.

4 Results and discussions

In the research study integrating road traffic data with building energy consumption using machine learning techniques, we observed a strong correlation between traffic patterns and energy usage in buildings. The machine learning models effectively predicted energy consumption based on traffic density, time of day, and weather conditions. High traffic periods corresponded to increased energy demand in nearby buildings, indicating a potential for optimizing energy management strategies. The results suggest that leveraging machine learning in this context holds promise for developing real-time energy optimization systems that respond dynamically to traffic fluctuations, ultimately leading to enhanced energy efficiency and sustainability in urban environments.

Compute the weighted error of the weak classifier:

$$\varepsilon (t) = \Sigma {\left\{i=1\right\}}^{N}* {w }_{i}* ({y }_{i})\ne {h}_{t}({x}_{i})$$
(5)

where \({\text{y }}_{\text{i}}\) is the true label of the ith training example, and \({\text{h}}_{\text{t}}\)(\({\text{x}}_{\text{i}}\)) is the prediction of the weak classifier on the ith example. Compute the weight of the weak classifier:

$$\alpha \left( t \right) = 0.5 \times \ln \left( {\frac{1 - \varepsilon \left( t \right)}{{\varepsilon \left( t \right)}}} \right)$$
(6)

Update the weights of the training examples:

$$w_{i} = w_{i} *\exp (**(x_{i} ))$$
(7)

Normalize the weights so that they sum up to 1:

$$W_{i} = \frac{{W_{i} }}{{Z_{t} }}$$
(8)

where Zt is a normalization factor given by the sum of all weights:

$$Z_{t} = \sum {(i = 1)^{N} } *w_{i}$$

Euclidean distance calculation:

The KNN algorithm uses the Euclidean distance to measure the similarity between data points. The Euclidean distance between two points, represented as vectors, x and y, in an n-dimensional space is given by Euclidean Distance

$$f\left( {x, y} \right) = sqrt\left( {\left( {x_{1} - y_{1} } \right)^{2} + \left( {x_{2} - y_{2} } \right)^{2} + ... + \left( {x_{n} - y_{n} } \right)^{2} } \right)$$
(9)

Compute the exponentially decaying average of past gradients: m = β1 * m + (1—β1) * ∇θJ(θ), where β1 is the first-moment decay rate (typically set to 0.9).

Update the second-moment estimate:

Compute the exponentially decaying average of past squared gradients:

$$v = \beta_{2} * v + \left( {1 - \beta_{2} } \right)* \left( {\nabla \theta J\left( \theta \right)\theta J\left( \theta \right)} \right)$$
(10)

where \({\upbeta }_{2}\) is the second-moment decay rate (typically set to 0.999).

Bias correction:

Compute bias-corrected first-moment estimate:

$${}^{ \wedge }m = \frac{m}{{1 - \beta^{\frac{t}{1}} }}$$
(11)

Compute bias-corrected second-moment estimate:

$${}^{ \wedge }v = \frac{V}{{1 - \beta^{\frac{t}{2}} }}$$
(12)

Update the parameters:

Update the parameters using the bias-corrected estimates:

$$\theta = \frac{\theta - \alpha *m}{{\left( {\surd \left( {{}^{ \wedge }v} \right) + \varepsilon } \right)}}$$
(13)

where α is the learning rate and ε is a small constant (e.g.,\({10}^{-8}\)) added for numerical stability.

Preprocessing is used to calculate machine learning models such as Random Forest, Decision Tree, AdaBoost, Knearest Neighbor, and proposed model metrics. Preprocessing requires training the dataset for proper predictions. Jupiter Python is used for all classification and prediction analyses. The metrics given below provide further context for the research as well as clear projections. As seen in Table 1, The proposed model provides great accuracy while taking less computational time.

In Table 1, we can observe the performance metrics for different algorithms after a thorough analysis. The Random Forest algorithm achieved an accuracy of 86.91%, a precision of 78.28%, a recall of 86.81%, and an F1-score of 79.14%. The Decision Tree algorithm had similar results with an accuracy of 86.87%, precision of 78.04%, recall of 86.89%, and an F1-score of 79.03%. The AdaBoost Classifier showed slightly improved performance with an accuracy of 88.08%, precision of 79.23%, recall of 86.81%, and an F1-score of 79.08%. The KnearestNeighbor algorithm achieved an accuracy of 84.53%, precision of 77.13%, recall of 85.05%, and an F1-score of 79.63%. Finally, the Proposed Model outperformed the other algorithms, obtaining an accuracy of 95.76%, precision of 89.87%, recall of 97.23%, and an F1-score of 89.41%. The F1 score is particularly useful for evaluating models as it considers precision and recall and provides a single metric that balances them. The provided metrics can be further analyzed to make informed decisions based on the desired trade-offs between accuracy, precision, recall, and score. Additionally, the error rate and loss function can be considered as measures of model performance, where lower values indicate better performance. The computational time is also an essential factor to consider, as it impacts the efficiency of the algorithms in real-time applications.

Learning Rate (α):

Notation: α

Equation:

$$\theta_{new} = \theta_{old} - \alpha * \nabla J\left( {\theta_{old} } \right)$$
(14)

where \({\uptheta }_{\text{old}}\) and \({\uptheta }_{\text{new}}\) are the old and updated parameter values, ∇J(\({\uptheta }_{\text{old}}\)) is the gradient of the loss function concerning the parameters.

Number of Iterations (epochs):

Notation: epochs.

Equation: Loop for i in range(epochs): # Training iterations.

Regularization Parameter (λ):

Notation: λ

Equation:

$$\text{J}(\uptheta ) =\text{ Loss}(\uptheta ) +\uplambda *\text{ Regularization}(\uptheta )$$
(15)

where J(θ) is the regularized loss function, Loss(θ) is the original loss function, and Regularization(θ) is the regularization term.

Number of Hidden Units:

Notation: \(\text{Hidden}\)

Equation: Number of hidden units in the neural network architecture.

Kernel Parameters (e.g., Gaussian Kernel):

Notation: σ (sigma).

Equation

$$K\left( {x, x^{\prime } } \right) = \exp^{{\frac{{\left( {\left( {\left| {\left| {x {-} x^{\prime } } \right|} \right|} \right)^{2} } \right)}}{{\left( {2*\sigma^{2} } \right)}}}}$$
(16)

where K is the kernel function, x and \(x^{\prime }\) are data points, and \(\left( {\left| {\left| {x {-} x^{\prime}} \right|} \right|^{2} } \right)\) is the squared Euclidean distance between x and x’s.

In Table 2, the model’s performance improves as the number of epochs increases, leading to higher accuracy, precision, recall, and F1-Score. The metrics used in the evaluation provide a comprehensive understanding of the model’s performance, taking into account both true positives and negatives and false positives and negatives, which is essential in imbalanced datasets.

In Table 3, accuracy measures the proportion of correctly classified instances out of the total instances in the dataset. Precision measures the proportion of true positive predictions (correctly predicted positive instances) out of all positive predictions made by the model. Recall measures the proportion of true positive predictions (correctly predicted positive instances) out of all actual positive instances in the dataset. F1-Score is the harmonic mean of precision and recall. It balances precision and recall, especially when dealing with imbalanced datasets. High accuracy, precision, recall, and F1-Score are desirable in a machine-learning context. However, choosing the most appropriate metric depends on the specific problem and the associated costs of false positives and negatives.

4.1 Accuracy

Machine learning model accuracy measures its ability to classify or predict data correctly. It’s the ratio of correct predictions to total predictions, e.g., 90% accuracy means 90 correct predictions out of 100. While useful for balanced classes, it needs more balanced data or multi-class scenarios. High accuracy doesn’t guarantee overall effectiveness or reflect class imbalances. In such cases, supplementary metrics like precision, recall, and F1 score provide a more comprehensive evaluation. Precision emphasizes correct positive predictions, recall focuses on true positives, and the F1 score balances both, aiding in a holistic assessment of model performance.

$$\text{Accuracy }= \frac{\text{Number of correct predictions}}{\text{Total number of predictions}}$$
(17)

4.2 Precision

Precision, a key machine learning metric, assesses a model’s accuracy in identifying positive instances. It calculates the ratio of true positives (correctly classified positives) to all predicted positives (true positives + false positives). In binary classification tasks, precision is vital for reliable identification. High accuracy minimizes false positives but can reduce the model’s ability to detect all true positives. Achieving an optimal balance between precision and recall ensures top performance, guaranteeing accurate predictions while minimizing overlooked positives.

$$\text{precision }=\frac{\text{true positives }}{\text{true positives }+\text{ false positives}}$$
(18)

4.3 Recall

Recall that machine learning measures the ability of a model to identify all relevant instances within a dataset correctly. It quantifies the ratio of true positive predictions to the total actual positives. High recall indicates fewer false negatives, which is crucial for tasks like medical diagnosis, where missing positive cases can be costly.

$$\text{Recall }= \frac{\text{true positives}}{\text{true positives} + \text{false} \text{negatives}}$$
(19)

4.4 F1-score

The F1 score in machine learning is a metric that balances precision and recall. It combines both metrics into a single value, comprehensively measuring a model’s performance. It’s particularly useful when dealing with imbalanced datasets or when there’s a need to balance minimizing false positives and negatives. The F1 score is calculated as the harmonic mean of precision and recall and ranges between 0 and 1, where higher values indicate better model performance.

$$F1-\text{score} = 2 * \frac{\text{precision} * \text{recall}}{\text{precision} + \text{recall}}$$
(20)

4.5 Error rate

The error rate in machine learning represents the discrepancy between predicted and actual outcomes in a model. It quantifies the model’s accuracy, with lower error rates indicating better performance. Reducing error rates is a key goal, achieved through refining algorithms, optimizing data preprocessing, and selecting appropriate models. Lower error rates enhance the model’s reliability and applicability in various domains.

$$\text{Error} \text{Rate} = \frac{\text{Number of incorrect predictions}}{\text{Total number of predictions}}$$
(21)

4.6 Computational time

Computational time in machine learning refers to the duration required for a model to process and analyze data, make predictions, and refine its parameters during training. It’s a critical factor impacting the model’s efficiency and scalability. Efficient algorithms, hardware acceleration, and parallel processing can help reduce computational time, making machine-learning models more practical for real-world applications.

5 Intelligent road traffic routing and building energy

Air quality and noise pollution are critical urban challenges. Enhancing building insulation and utilizing piezoelectric materials can mitigate both noise and vibrations. Piezoelectric materials, when integrated into infrastructure, can convert mechanical vibrations from traffic into electrical energy. Intelligent road traffic management systems optimize traffic flow, reducing congestion and emissions. Effective building insulation not only aids in noise reduction but also improves energy efficiency, contributing to better air quality. Addressing these issues collectively can create healthier, more sustainable urban environments, striking a balance between human comfort and environmental preservation.

Recall measures the fraction of true positives out of all actual positives, and the F1-score is a weighted average of precision and recall in Fig. 3. The choice of loss function and error rate is also critical in comparing classifiers. The loss function quantifies the difference between predicted and actual values, while the error rate is the proportion of misclassifications in the test dataset. Different classifiers may use different loss functions and have varying error rates depending on the nature of the problem and the data used. Therefore, in comparing classifiers, it is crucial to consider accuracy, precision, recall, and F1-score, as well as the loss function and error rate. A comprehensive evaluation of these metrics can help identify the strengths and weaknesses of different classifiers and determine the best approach for a particular problem.

Fig. 3
figure 3

Classifiers comparison of accuracy, precision, recall, F1-score, loss function, error rate

In Fig. 4, you could perform a statistical analysis using the dataset to explore the relationship between the number of vehicles involved in an accident and accident severity. In Fig. 6, it’s important to note that while data analysis can provide insights into the causes of accidents and potential ways to reduce them, it’s ultimately up to individuals and organizations to take action to improve road safety.

Fig. 4
figure 4

Road accidents due to different factors on 1-congestion, 2-accidents and 3-morality

This may involve implementing better infrastructure, improving driver education and training, and promoting safe driving habits. Draw conclusions and make recommendations based on your analysis and modeling; you can conclude the factors that contribute to accidents on different road types and make recommendations for improving road safety. These recommendations can be used by policymakers, transportation agencies, and other stakeholders to reduce the incidence of road accidents.

The congestion can increase the likelihood of accidents due to the increased number of vehicles on the road, resulting in slower traffic flow, longer travel times, and frustration among drivers. Additionally, congestion can lead to reckless driving behavior, such as tailgating or cutting off other drivers, increasing the risk of accidents. Accidents are a common cause of road accidents and can occur for various reasons, including driver error, vehicle malfunctions, and poor road conditions. Some common types of accidents include rear-end collisions, side-impact collisions, and rollovers. Poor driving behavior, such as speeding, distracted driving, and driving under the influence of drugs or alcohol, can also contribute to road accidents. Additionally, moral factors such as a lack of consideration for other drivers or a disregard for traffic laws can also play a role in causing accidents.

5.1 Curtail carbon emissions

Promote electric vehicles (EVs) use by providing incentives, tax breaks, and financial assistance for EV purchases. Build an electric charging system to make EV charging easy and common and invest in the research and development of hydrogen fuel cell vehicles. These vehicles can replace conventional gasoline as they emit only water vapor and no other emissions. To develop and use renewable materials such as algae, crop waste, or waste to produce biofuels such as biodiesel and ethanol and to promote their use. These fuels have a great impact on reducing carbon emissions. Public transportation needs to be improved and expanded to reduce the number of private vehicles on the roads. Efficient and affordable public transport can encourage users to leave their cars at home. Use smart traffic management tools to increase traffic. Less traffic, fewer interruptions. Transport and urban planning can be incorporated into smart city plans to create sustainable cities. Develop and enforce strict regulations regarding the fuel economy of new vehicles. The auto industry is encouraged to create a more efficient engine and heavy equipment to improve the car’s overall performance. Build mixed communities and cities that reduce the need for long-term travel. This reduces the total number of trips required and reduces carbon emissions. Publish educational programs promoting eco-friendly driving, such as reducing idle time, using cruise control, and inflating tires. Investing in research to develop high-tech technologies, including multi-use power generators, heavy-duty devices, and accumulators. Perform inspections and strict regulations to ensure vehicles are compliant.

5.2 Minimized fuel consumption

A careful interplay between driving tactics and route selection is required to optimize fuel usage within the setting of traffic trajectories. Drivers can use smooth acceleration and deceleration by taking advantage of traffic patterns, which eliminates the need for numerous stops and starts that increase fuel usage. To avoid needless braking, drivers should adjust their speed to match traffic flow. This results in better fuel economy. Additionally, choosing routes with less traffic or using real-time traffic data to avoid congestion helps keep a constant driving pace, ultimately saving fuel. In essence, synchronizing driving actions with traffic flow allows for a more efficient use of fuel resources. Create a cutting-edge fuel injection and engine management system that uses real-time information from multiple sensors and inputs to modify the fuel–air mixture and engine settings dynamically. This technology will optimize fuel combustion for optimal efficiency in various driving situations. Utilize a network of sensors to collect information on various variables, such as the vehicle’s speed, engine temperature, load, throttle position, air quality, road gradient, and more. Use a machine learning system that constantly learns and adjusts to the actions of the driver, the road, and the surrounding environment. This algorithm will optimize the fuel–air combination and ignition timing for maximum effectiveness and performance. Make a dynamic engine map and real-time changes in response to sensor and machine learning algorithm input. The conventional fixed engine maps will be replaced by this map, enabling increased versatility and flexibility. Create predictive skills to prepare for shifting road conditions. For instance, if the system anticipates a downward slope, it can momentarily change the engine settings to capitalize on the car’s momentum and cut fuel use. Integrate the system with the transmission to enhance gear changes and keep the engine running efficiently under various driving conditions.

5.3 Energy building

Carbon emissions, fuel consumption, and energy usage in buildings are interconnected aspects that significantly impact our environment and sustainability efforts. Carbon emissions refer to the release of carbon dioxide and other greenhouse gases into the atmosphere, primarily from human activities such as burning fossil fuels like coal, oil, and natural gas. These emissions contribute to climate change and global warming, with detrimental effects on our planet.

Fuel consumption is the amount of fuel a vehicle, machinery, or equipment uses to generate energy. The type and amount of fuel consumed directly affect carbon emissions. Fossil fuels are the primary source of energy for transportation and heating, making it crucial to optimize fuel consumption to minimize environmental harm. In buildings, energy consumption is a major contributor to carbon emissions. Buildings use energy for heating, cooling, lighting, appliances, and other purposes. The source of this energy, often fossil fuels, significantly influences the level of carbon emissions associated with the building. Sustainable practices, such as using renewable energy sources like solar or wind power, can help reduce both energy consumption and carbon emissions in buildings.

To mitigate the negative impact of carbon emissions and fuel consumption, we need to focus on improving energy efficiency in buildings. This involves employing energy-saving technologies, better insulation, efficient appliances, and promoting behavioral changes to reduce energy waste. Transitioning to cleaner and renewable energy sources is another critical step towards reducing carbon emissions and achieving a more sustainable future.

5.4 Piezoelectric materials

Piezoelectric materials integrated within roadways harness mechanical pressure from passing vehicles, converting it into electrical energy. This innovative infrastructure captures the vibrations and movements, transforming them into a sustainable power source. As vehicles traverse these piezoelectric-embedded roads, the materials generate electricity that can be utilized for various applications, promoting energy efficiency and reducing reliance on traditional power grids. This advancement exemplifies a promising avenue for sustainable energy generation, aligning with the global drive towards renewable resources and promoting greener, smarter infrastructure for the future.

5.5 Loss function

A loss function quantifies the disparity between predicted and actual values in machine learning. It guides model optimization by minimizing this error. Popular loss functions include mean squared error for regression and categorical cross-entropy for classification. The choice of loss function directly influences model training, determining how effectively the model learns patterns in data.

$$\text{L }= -\Sigma \left(\text{y }*\text{ log}\left(\text{p}\right)+ \left(1-\text{y}\right)*\text{ log}\left(1-\text{p}\right)\right)$$
(22)

where y represents the true label (0 or 1), and p represents the predicted probability.

5.6 Mortality

Mortality calculation in road traffic congestion and accidents using machine learning can be approached in several ways. One possible method is to use predictive modeling techniques to analyze historical data on road traffic congestion and accidents and identify patterns and trends associated with higher mortality rates. The following are some steps that can be taken to develop a machine-learning model for mortality calculation:

The machine learning methods in Table 4 predict mortality, accidents, and congestion. However, the proposed model predicts these outcomes well based on data from Tables 1, 2 and 3. Our proposed model is essential in raising the prediction’s accuracy rate and precision.

Table 4 Proposed model compared with other models

5.7 Accidents

Road traffic accidents occur due to various factors, including human error, impaired driving, speeding, adverse weather conditions, and vehicle defects. These incidents result in injuries, fatalities, and property damage, posing significant societal and economic burdens. To mitigate accidents, measures such as driver education, stricter traffic regulations, improved road infrastructure, and advanced safety technologies are crucial for enhancing road safety and reducing the toll of road traffic accidents.

5.8 Congestion

Traffic congestion refers to the gridlock and slowdown of vehicles on roadways due to excessive demand, often during peak hours. It results in longer travel times, increased fuel consumption, and air pollution. Mitigation strategies include traffic management systems, public transportation enhancement, carpooling incentives, and urban planning improvements. These measures aim to alleviate congestion and enhance overall transportation efficiency, benefiting commuters and the environment.

In Fig. 5, once you have selected your features, you can train your classifiers using various machine learning algorithms such as decision trees, random forests, adaboost, KNN, and the proposed model. After training, based on recent data, you can use the trained classifiers to predict values for Mortality, Accidents, and Congestion.

Fig. 5
figure 5

Predicted values of classifiers for mortality, accidents, and congestion

The metrics in Table 5 are derived from the dataset’s class mobility of highway vehicles, which is described in the data accessibility section below. The global routing system of the internet depends on the Border Gateway Protocol to function properly. It is essential to ensure that data packets are delivered effectively and dependably across various networks and autonomous systems. Link-state protocols support big and complex networks while efficiently using network resources. With its quick convergence and effective use of network resources, EIGRP is made to handle routing within large, complicated networks.

Table 5 Comparison of three different routing protocols

5.9 EIGRP in intelligent emergency routing response system (IERRS)

IERRS needs an adaptive, proficient and dependable routing technique for the most effective traffic management of emergency vehicles. Indeed, the yen features EIGRP as the best-suited protocol for the course since it offers fast convergence, no counting loops, and changes sensitivity in Fig. 6.

  • Key functionalities of EIGRP in IERRS:

Fig. 6
figure 6

Intelligent emergency routing response system in great Britain using (EIGRP)

Dynamic route updates: As for the key principles, EIGRP is a fast and efficient method that quickly reacts to changes in roads and, traffic situations and emergencies to make correct routing decisions.

Loop-free path calculation: The DUAL algorithm ensures a network does not get trapped in a routing loop, which is significant in avoiding any congestion and guaranteeing that the emergency response vehicles get to their destination promptly.

Load balancing: EIGRP can load balance, spreading the traffic between multiple links in order to provide system redundancy and control congestion during an emergency.

Metric calculation: Also, EIGRP takes into account bandwidth, delay, load, and reliability as the criterion to choose the next best path which would help in routing the emergency vehicles through the best path.

  • Implementation and Benefits

To effectively implement EIGRP in IERRS, the following steps can be considered: To implement EIGRP in IERRS effectively, the following steps can be considered.

Network topology mapping: The creation of a network diagram of the transportation system for the roads, intersections and movement patterns of traffic must be drawn.

EIGRP configuration: The next steps involve setting up EIGRP on routers in the IERRS network. This involves defining and setting the autonomous systems, networks and metrics.

Real-time data integration: Enhance the EIGRP process with real-time traffic information, weather conditions and or an incident report.

Emergency vehicle prioritization: Provide ways of filtering and directing the traffic to accord preference to emergency vehicles.

Continuous monitoring and optimization: To optimize the efficiency of the system and to adjust routing parameters based on the EIGRP performance and the general state of the network.

Case study:

Suppose a big city at some point in time is facing a very bad traffic jam occasioned by an accident. Based on EIGRP, IERRS quickly determines the best pathways that the ambulance has to take when getting to the accident scene with references to street closures, traffic congestion, and vicinity. Since the converging of routing is swift and almost instant, ambulances are redirected as the condition changes to enable the least response time and thus save lives.

Considerations:

Redundancy: It is recommended to have multiple EIGRP configurations to make the system more reliable in the case of router failure.

Security: Secure EIGRP messages so that they cannot be intercepted and the routing data modified by unauthorized parties.

Scalability: Structure the IERRS network with a view to expanding and growing the transportation system in the future.

Hence, if EIGRP is implemented successfully, it will help IERRS to have a better emergency response system, improved response time and better safety of the public.

Table 6, air quality in Great Britain is monitored by the Department for Environment, Food & Rural Affairs (DEFRA). They use a network of air quality monitoring stations to measure pollutants like nitrogen dioxide, particulate matter, sulfur dioxide, ozone, and carbon monoxide. This data helps assess air quality and formulate policies to improve environmental health across the country.

Table 6 Data on air quality in great Britain

Table 7, road traffic emissions in Great Britain contribute significantly to air pollution. They mainly consist of nitrogen dioxide (NO2) and particulate matter (PM). Emissions come from vehicles burning fossil fuels, particularly in urban areas. Efforts to reduce emissions include promoting electric vehicles, improving public transportation, and implementing stricter emissions standards to mitigate the impact on air quality and public health.

Table 7 Data on road traffic emissions in great Britain

Table 8, Great Britain is investing in piezoelectric materials for energy conversion. These materials can convert mechanical stress into electrical energy. Applications range from energy harvesting in infrastructure to wearable devices. The research and development aim to enhance efficiency and broaden applications, contributing to sustainable energy solutions and advancing technological innovation within the country.

Table 8 Piezoelectric materials conversion in great Britain

Tables 9, 10, in Great Britain, improving building insulation reduces heating demands, consequently lowering energy consumption and road traffic emissions. Energy-efficient buildings decrease the need for heating, positively impacting air quality. This integrated approach aligns with sustainability goals, enhancing both environmental and public health by minimizing pollution and optimizing energy use within the built environment.

Table 9 Road traffic data in great Britain
Table 10 Data of buildings insulation

Table 11, traffic vibrations in urban areas can impact building integrity. Prolonged exposure to vibrations can affect structural stability and occupant comfort. Engineers and architects in Great Britain employ design strategies and materials to mitigate these effects. Innovative solutions aim to enhance building resilience, ensuring structures can withstand vibrations from road traffic while maintaining safety and habitability standards.

Table 11 Traffic vibrations and building integrity

Comparing different machine learning solutions to solve traffic problems, the proposed model is shown to have a higher accuracy of up to 0.95. 76% in Table 12. However, Dense CNN and Random Forest also show good performance, but in practical applications, the overall performance of these models is affected by many other indicators such as efficiency, versatility, and analytical readability. More so, the said architecture and the details implied in implementing the proposed model offer a vital framework for developing a proper assessment of its benefits compared to previous approaches.

Table 12 Comparison study of models

Our proposed model, SGDo-HP-LR-GP, has demonstrated exceptional precision in key contributions, as evidenced from Tables 6, 7, 8, 9, 10 and 11. Intelligent traffic routing emerges as a crucial factor in optimizing building energy consumption. By effectively managing traffic, we not only reduce air pollution and noise but also minimize building vibrations, consequently saving energy. Piezoelectric materials play a pivotal role in converting vehicle kinetic energy into electrical power, which can be utilized for nearby buildings and street lighting. Therefore, efficient traffic flow control directly impacts building energy conservation, showcasing the intricate interplay between intelligent routing and sustainable building practices.

6 Conclusion

The key contributions in the research study include the integrated relationship between urban traffic and the built environment, highlighting a complex interplay of challenges and potential solutions. Mitigating the adverse effects of traffic emissions on air quality necessitates enhanced filtration systems in HVAC systems, although at the cost of increased energy consumption. On the bright side, the integration of piezoelectric materials in roadways offers a promising avenue to utilize vehicle-induced vibrations and convert them into a sustainable energy source, potentially relieving energy needs for nearby buildings and street lighting. However, the escalating traffic volumes and resulting noise levels call for improved building insulation, amplifying energy requirements for maintaining a comfortable indoor environment. Moreover, the structural implications of traffic-induced vibrations underscore the necessity for additional energy investments in structural reinforcements and ongoing maintenance efforts for the integrity and safety of buildings in high-traffic urban areas. Balancing sustainable energy solutions and the challenges posed by urban traffic remains a critical endeavor for creating healthier, energy-efficient, and resilient urban environments.

7 Future work

These findings pinpoint the interconnection between traffic patterns characteristic of big cities, constructed space, and energy use. Although the use of piezoelectric technology to convert the kinetic energy from roads into electricity is a concept that inspires the development of a sustainable energy source, the issues of air pollution, noise and structures bring so many very challenging factors. These factors thus require innovative means to have the spatial environment responsive to the current need and challenge of traffic and urbanization while being sound and sustainable in its consumption of resources. The research may be continued by further developing other machine learning methods, for instance, reinforcement learning for traffic control and power production, or generative adversarial networks for emulation and forecasting of cities. Further, the latest endeavor in the domain of Sensing technology and Data fusion methodology can be used to acquire and process holistic information regarding traffic flow, air quality, noise level, and even building performance, as a result of which, management can make informed decisions which can, in turn, can form the base to develop so many forecasting models to govern the Utilities of Smart city.