## 4 Proposed Approach  
The proposed methodology outlines a systematic framework for securing IoT networks, as depicted in Figure 3. This approach follows a multi-stage process.  
Figure 3: The proposed approach.  
Initially, an appropriate IoT attack dataset is selected to train and evaluate machine learning models for classifying IoT network traffic. The second stage focuses on preprocessing the dataset by fixing null and missing values, using label encoding, and normalizing the data to ensure consistency. To rectify class imbalances and improve the model's generalizability across different classes and subcategories, the dataset is balanced by leveraging the SMOTE technique in the third step. The dataset is divided into training and testing subgroups in the fourth step. The training dataset is used for model development and optimization, while the testing dataset is reserved for evaluating performance. In the fifth stage, machine learning models--including Logistic Regression, Random Forest, XGBoost, and K-Nearest Neighbor--are employed to classify network traffic, distinguishing between benign and attack categories. The sixth step compares the accuracy and feature important metrics of various models to assess their performance and identify the best model for additional XAI investigation. To increase transparency and offer insights into the chosen model's decision-making process, XAI methods like LIME and SHAP are applied in the seventh stage.  
The eighth stage entails cross-validating the results obtained from LIME and SHAP, ensuring transparency in the predictions. In the ninth stage, the selected or the best-performing model's predictions are evaluated and analyzed using XAI methods, focusing on identifying and analyzing the most impactful features highlighted by them to assess their consistency and reliability. Lastly, a recursive feature removal technique is used in the tenth step to improve the model's prediction performance and accuracy. This comprehensive framework ensures the development of a robust, transparent, and reliable security solution for both existing 5G networks and emerging 6G networks. Each step in this methodology is explained in depth in the following subsections.  
Algorithm 1 outlines the pseudocode for the proposed approach. The pseudocode offers a systematic and organized depiction of the methodology used to create a robust, transparent, and reliable security solution. It details each step, including dataset selection, preprocessing, machine learning model training, the application of XAI techniques, and performance enhancement, ensuring a clear approach aligned with the goal of improving IoT network security in current and future network environments.  
```
START // Step 1: Dataset Selection Load CICIoT2023_attack_dataset // Step 2: Preprocessing FOR each feature IN CICIoT2023_attack_dataset: IF feature has missing/null values: Impute values using mean/median/mode ENDIF IF feature is categorical: Apply label encoding ENDIF Normalize all numerical features
``` // Step 3: Handle Class Imbalance using SMOTE IF dataset is imbalanced: Apply SMOTE to balance classes ENDIF // Step 4: Dataset Splitting [train_set, test_set] = Split_dataset(IoT_attack_dataset, ratio = 0.8) // Step 5: Train Machine Learning Models Initialize models = [LogisticRegression, RandomForest, XGBoost, KNearestNeighbor] model_results = {} FOR model IN models: Train model on train_set Evaluate model on test_set model_results[model] = Calculate_performance_metrics(model) ENDFOR // Step 6: Compare Model Performance best_model = Select_best_model(model_results) // Step 7: Apply XAI Methods \(\text{\text{\text{\text{\text{\text{\text{\text{\text{\text{\text{\text{\text{\