## 4 The Dataset Usage
### Data Extraction and Feature Selection
#### 4.1.4 Experimental Setup  
The experiments were conducted on Google Colab Pro [43], utilizing a high-RAM environment (50.99 GB) with an optimized CPU. The primary libraries used for feature engineering and model training included the following:  
* scikit-learn [44] for machine learning models, hyperparameter tuning, and cross-validation;
* Pandas [45] for data manipulation and preprocessing;
* Matplotlib 3.9.0 & Seaborn 0.3.12 for data visualization;
* Google Colab's cloud-based runtime to leverage computational efficiency. We employed multiple machine learning classifiers for model training, including Logistic Regression, Support Vector Machines (SVM), Random Forest, XGBoost, and Gradient Boosting, as shown in Table 4. Hyperparameter tuning was performed using GridSearchCV from the sci-kit-learn library, with k-fold cross-validation (k = 3) to ensure robustness. The best-performing model, a fine-tuned logistic regression and support vector machine, achieved an accuracy of 98.71% on the test set, demonstrating its effectiveness in distinguishing vulnerable code snippets from non-vulnerable ones. Performance across training, validation, and test sets was evaluated to mitigate overfitting. The following metrics are used for evaluation: accuracy, precision, recall, and F1 score. - Accuracy is the ratio of correctly predicted functions to the total number of functions. - Precision measures the model's ability to predict vulnerable functions accurately. - Recall assesses the number of correct predictions made for all vulnerable functions in the dataset. - F1 Score is the harmonic mean of precision and recall values, providing a single score that makes it a more valuable metric. Formulas of performance metrics used in the study are as follows:  
\[Precision=\frac{TP}{TP+FP} \tag{1}\] \begin{table}
\begin{tabular}{l c c c c c c c c} \hline \hline
**Model** & **Accuracy** & \begin{tabular}{c} **Precision** \\ **(0)** \\ \end{tabular} & \begin{tabular}{c} **Recall** \\ **(0)** \\ \end{tabular} & \begin{tabular}{c} **F1-Score** \\ **(0)** \\ \end{tabular} & \begin{tabular}{c} **Precision** \\ **(1)** \\ \end{tabular} & \begin{tabular}{c} **Recall** \\ **(1)** \\ \end{tabular} & \begin{tabular}{c} **F1-Score** \\ **(1)** \\ \end{tabular} & \begin{tabular}{c} **Hyperparameters** \\ **(1)** \\ \end{tabular} \\ \hline RandomForest & 0.9849 & 0.9864 & 0.9858 & 0.9861 & 0.9831 & 0.9838 & 0.9835 & \begin{tabular}{c} \{’max\_depth’: 8, \\ _n_estimators’: \\ 200\} \\ \end{tabular} \\ \hline GradientBoosting & 0.9735 & 0.9732 & 0.9781 & 0.9757 & 0.9738 & 0.9679 & 0.9708 & \begin{tabular}{c} \{’learning\_rate’: \\ 0.01, ‘max\_depth’: \\ 3, ‘n\_estimators’: \\ 100\} \\ \end{tabular} \\ \hline SVM & 0.9871 & 0.9883 & 0.9879 & 0.9881 & 0.9856 & 0.9860 & 0.9858 & \
\begin{tabular}{c} \{’C’: 0.5, ‘kernel’: \\ ‘linear’\} \\ \end{tabular} \\ \hline LogisticRegression & 0.9871 & 0.9881 & 0.9881 & 0.9881 & 0.9858 & 0.9858 &
\begin{tabular}{c} \{’C’: 0.5, ‘penalty’: \\ ‘12’\} \\ \end{tabular} \\ \hline \hline \end{tabular}
\end{table} 
Table 4: Performance results with the best hyperparameters. \[Recall=\frac{TP}{TP+FN} \tag{2}\]  
\[F1-Score=2\times\frac{Precision\times Recall}{Precision+Recall} \tag{3}\]  
\[Accuracy=\frac{TP+TN}{TP+TN+FP+FN} \tag{4}\]  
Definitions are as follows:  
* TP (True Positive)--Correctly predicted vulnerable code. * TN (True Negative)--Correctly predicted non-vulnerable code. * FP (False Positive)--Incorrectly classified safe code as vulnerable. * FN (False Negative)--Incorrectly classified vulnerable code as safe. Figure 4 presents a comparative analysis of machine learning models for vulnerability detection. The bar chart illustrates the performance of four models--Random Forest, Gradient Boosting, SVM, and Logistic Regression--across key evaluation metrics, including accuracy, precision, recall, and F1-score. The results are reported separately for class 0 (non-vulnerable) and class 1 (vulnerable) instances.