An IDS (Intrusion Detection System) is essential for network security experts, as it allows one to identify and respond to abnormal traffic present in a network. An IDS can be utilized for evaluating the various types of malicious attacks. Hence, detecting intrusions has become a significant research area in the contemporary era, especially with the evolution of technologies. With the progress of ML (Machine Learning)-based algorithms, researchers have striven to perform optimal ID. However, most of these studies lag in accordance with their accuracy rate. Thus, to attain a high accuracy rate in ID, the present study proposes ML-based meta-heuristic algorithms, as these approaches possess innate merits of determining near-optimal solutions in limited time and are capable of dealing with multi-dimensional data. The study proposes OWSA (Optimal Whale Sine Algorithm) for selecting suitable and relevant features. With an exclusive optimization process using the SCA (Sine Cosine Algorithm), this study proposes to combine SCA with WOA (Whale Optimization Algorithm) for mitigating the demerits of both, with its hybridization thereby achieving OWSA. Following this, AWRF (Artificial Neural Network Weighted Random Forest) is proposed for classification. The main intention of this process is to propose a weight-updating process for discrete trees in the RF model. The proposed approach is motivated by avoiding overfitting and attaining stability and flexibility. This approach is assessed with regard to performance via a comparative analysis, so as to uncover the best performance of this proposed technique in ID.