Many natural phenomena, including geologic events and geophysical data, are fundamentally nonstationary. They may exhibit stationarity on a short timescale but eventually alter their behavior in time and space. We developed a 2D adaptive prediction filter (APF) and further extended this to a 3D version for random noise attenuation based on regularized nonstationary autoregression (RNA). Instead of patching, a popular method for handling nonstationarity, we obtained smoothly nonstationary APF coefficients by solving a global regularized least-squares problem. We used shaping regularization to control the smoothness of the coefficients of APF. Three-dimensional space-noncausal APF uses neighboring traces around the target traces in the 3D seismic cube to predict noise-free signal, so it provided more accurate prediction results than the 2D version. In comparison with other denoising methods, such as frequency-space deconvolution, time-space prediction filter, and frequency-space RNA, we tested the feasibility of our method in reducing seismic random noise on three synthetic data sets. Results of applying the proposed method to seismic field data demonstrated that nonstationary APF was effective in practice.