Sleep apnea refers to a sleep disorder consist of inconsistent breathing during sleep for extensive duration of time. During this, one faces difficulty in breathing leading to loss of oxygenated blood circulation in human body. It leads to damage in hippocampus region of the brain. Many medical problems like hypertension and inducing type two diabetes are also common in patients. The early-stage detection of apnea can save someone from these severe conditions. This work introduces the automatic apnea detection method using electrocardiogram (ECG) signals. The ECG signals are analyzed with the help of flexible analytic wavelet transform (FAWT) which allows the conversion of non-stationary ECG into predictable wavelets. Features for events of apnea and non-apnea are extracted by these wavelets. The extracted features are checked for their statistical significance and then fed into different kinds of machine learning algorithms for apnea events detection. In tested algorithms, the optimized ensemble is obtained the best classification results. The proposed approach for apnea detection has better performance as compared to other existing same dataset works.