Obstructive Sleep Apnea is a respiratory disorder that impairs sleep quality by causing respiratory arrest. An irregular breath delay or decrease of airflow during sleep is the hallmark of the apnea syndrome. According to the literature, approximately 2% of middle-aged women and 4% of middle-aged men are affected. The disease is diagnosed by the physician in two steps. In the first stage, the physician reviews the medical records obtained using the polysomnography system. The disease is diagnosed in two stages by the physician, who examines the patient records taken with the polysomnography system in the first stage. New diagnostic processes and equipment are required as a result of the negative aspects of this procedure. The heart rate variable (HRV) and electrocardiography (ECG) signals are used, and ECG records from the patient and control groups are obtained. The optical filter was used to clean ECG signals and heart rate variables (HRV) from patient and control classes. After that, the ECG signal was used to calculate the HRV parameter. The HRV and ECG signals were then used to extract functionality. Reduced machine learning techniques, such as random forest, SVM, and the kNN feature selection process, were used to classify the extracted features. To evaluate the classifiers’ efficiency, the sensitivity and specificity values, as well as the accuracy rates for each class in the test set, were computed, and a receiver operating characteristic curve was developed. The method can be realized with Random forest, Support Vector Machine, and KNN, which have the best accuracy of 82.5 percent, 97 percent, and 89 percent, respectively, using 11 ECG and HRV features, according to the results. The system will work with these success rates. It is possible to implement a realistic sleep/awake detection method when all of these factors are taken into account. This means that using machine learning and signal processing methods, the ECG signal can be used to diagnose obstructive sleep apnea.