Implementing Random Forest for Eye State Detection in an EEG-Based Brain-Computer Interface System - Muhammad Alfathan; Tri Sugihartono (Politeknik Ganesha Medan, 2026)
Eye state detection using Electroencephalogram (EEG) signals is a growing research area in Brain-Computer Interface (BCI) systems, with practical implications for drowsiness monitoring and assistive technologies. However, EEG signals are highly susceptible to extreme outliers caused by muscle artifacts and electrode interference, which significantly degrade model performance when left unaddressed. Previous studies have largely overlooked explicit outlier handling strategies and often rely solely on accuracy as the evaluation metric, which is insufficient for imbalanced class distributions. This study aims to implement the Interquartile Range (IQR) Clipping method for outlier handling on EEG signals and develop a Random Forest classification model to distinguish open-eye and closed-eye states, evaluated through seven comprehensive metrics. The EEG-Eye-State dataset from the UCI Machine Learning Repository, consisting of 14,980 samples across 14 EEG sensor features, was used. IQR Clipping with bounds [Q1 − 1.5×IQR, Q3 + 1.5×IQR] was applied to all sensors, followed by StandardScaler normalization and an 80:20 Stratified Train-Test Split. A Random Forest model with 100 estimators and balanced class weights was trained and validated using Stratified 10-Fold Cross-Validation. IQR Clipping successfully handled 12,737 outlier instances across all sensors without discarding any samples. The model achieved an accuracy of 92.49%, Balanced Accuracy of 92.14%, ROC-AUC of 0.9791, PR-AUC of 0.9759, F1-Score Macro of 0.9236, Matthews Correlation Coefficient (MCC) of 0.8486, and Cohen Kappa of 0.8474. Cross-validation confirmed model stability with a mean accuracy of 92.86% ± 0.36% and ROC-AUC of 0.9809 ± 0.0020. Feature importance analysis identified sensors O1 (11.81%), P7 (10.59%), and F7 (10.15%) as the most dominant contributors. These results confirm that combining IQR Clipping with Random Forest produces a stable, accurate, and neuroanatomically interpretable model for EEG-based eye state classification, offering a strong foundation for real-world BCI and driver drowsiness detection systems.