Gait recognition based on inertial sensor data develops rapidly. Recently, more and more studies are based on the data collected in-the-wild, where the data quality is limited. Thus, the requirement for data preprocessing is higher. In this work, an adaptive preprocessing algorithm, MAOMP, is proposed to extract the effective components in the gait data. Different from traditional denoising methods, MAOMP recovers valid data from scratch using sinusoidal bases adaptively by projecting signals and bases into the Hilbert space. It can remove invalid data to smooth the signals but highlight the essential extremums at the same time. Finally, MAOMP is evaluated on four publicly available datasets of different grades and three different neural networks. The quantization of SNR shows the data recovered by MAOMP is at a higher level. Compared to the two commonly used preprocessing methods, the performance of MAOMP can be more pronounced as the quality of the datasets decreases. The improvements of the recognition performance are more apparent in the ConvLSTM network compared to the CNN with the data recovered by MAOMP.