Contextual Contrastive Representation Learning with LightGBM for Intrusion Detection in Heterogeneous IoT Networks
Sunil Kumar, Sameeksha Khare, Isha Chopra, Jugul Kishor Gupta, Devendra Kumar, Wee How Khoh, Firoz Khan, Vivek Kumar SharmaThe increasing adoption of Internet of Things (IoT) technologies in smart farming has improved agricultural automation and decision-making while expanding the attack surface of interconnected devices and communication networks. Intrusion detection in these environments is challenged by heterogeneous network features, severe class imbalance, and evolving attack patterns. This study proposes CCRL-LightGBM, a contextual contrastive representation learning framework that integrates TabTransformer-based feature learning, supervised contrastive refinement, and Light Gradient Boosting Machine (LightGBM) classification. The framework was evaluated on the CICIoT2023 and CIC IoT-DIAD 2024 datasets using a unified preprocessing pipeline and compared with representative machine learning and deep learning models. Under random-stratified evaluation, CCRL-LightGBM achieved an accuracy of 99.63% and F1-score of 99.81% on CICIoT2023 and an accuracy of 99.39% and F1-score of 99.68% on CIC IoT-DIAD 2024. GPU inference latency was 3.78 ms per sample under the evaluated experimental conditions. In paired comparisons with TT–LightGBM, the CCRL-LightGBM configuration achieved higher F1-scores under temporal, source-disjoint, and device-disjoint evaluation protocols, with device-disjoint F1-scores of 93.31% on CICIoT2023 and 92.56% on CIC IoT-DIAD 2024. However, performance declined under stricter partitioning protocols, highlighting the challenges of generalization to temporally shifted traffic and previously unseen source or device groups. Unadapted cross-dataset evaluation further revealed limitations in transfer performance between the two benchmark environments. These results demonstrate strong benchmark-level performance and improved results relative to the baseline under the evaluated conditions while highlighting the need for further validation using agriculture-specific traffic and deployment-level measurements before operational suitability for smart-farming environments can be established.