The invention discloses a method and device for detection of a sleep apnea fragment based on unsupervised feature learning. The method includes the steps: collecting sleeping electrocardiosignals (ECG), performing analog-digital conversion on the ECG signals so as to obtain electrocardio digital signals, performing segmentation on the electrocardio digital signals according to minutes so as to obtain ECG segments, extracting a RR interphase sequence for correction according to the ECG segments, performing cubic spline interpolation and fast Fourier transform so as to obtain a frequency domainsequence, making a train set, constructing a stack-type sparse self-coding model, adopting an unlabeled data set to perform pre-training of a sparse self-encoder, performing unsupervised learning andfeature extraction on the frequency domain sequence, performing fine tuning on the stack-type sparse self-coding model by using a labeled train set, constructing a Softmax-hidden markov and time-dependent-cost-sensitive classification model, using the sparse self-coding model to obtain features and corresponding labels in the labeled train set, and training the Softmax-hidden markov and time-dependent-cost-sensitive classification model by using the features and corresponding labels in the labeled train set so as to obtain a sleep apnea classification model.