Sleep apnea (SA) is a potentially fatal sleep disorder where breathing regularly pauses and resumes during sleep, which results in regular awakenings. In this work, we introduced two efficient models which were tested on both the handcrafted and the latent features. To preprocess and segment the electrocardiogram (ECG) signals into multiple spectrums, this work uses a unique approach known as sliding singular spectrum analysis (SSSA). Later, we considered four time-frequency domain (TFD) features, such as spectral entropy (SE), signal energy (EN), dominant frequency (DF), and spike rhythmicity (SR) to precisely detect and classify SA from the ECG signals. To cope with the high-dimensional nature of the data, we have proposed a novel algorithm named subpattern-based principal component analysis (SPPCA), which can extract the most prominent features by delimiting the dimensions of the original features. To classify the ECG data, the low-dimensional TFD features were used to train and validate different machine learning (ML) models, such as extreme gradient boosting (XGB), support vector machine (SVM), Gaussian Naive Bayes (GNB), stochastic gradient descent (SGD), and K-nearest neighbor (KNN). Similarly, we implemented a deep learning (DL) framework named modified LeNet-5 CNN network (MLN-CNN), which extracts the hidden features to classify SA from the ECG signals. We used the Physionet Apnea ECG (PNEA) and St. Vincent's University Hospital/University College Dublin (UCD) databases for this study, which are publicly available. We evaluated both the proposed algorithms using various classification metrics. The metrics suggest that we achieved the highest accuracy of 100% and 97.1% on PNEA and 86.66% and 92.30% on UCD databases, respectively. The performance metrics of our proposed algorithms have shown a significant dominance over the latest state-of-the-art works. © 2020 IEEE.