The potato size and shape can affect the accuracy of predicting potato quality using near-infrared (NIR) spectroscopy. This study used NIR spectroscopy and a linear-nonlinear algorithm to eliminate the influence of potato size and shape on the accuracy of the prediction model for potato starch and moisture content. Savitzky-Golay (SG) filtering and four dimensionality reduction algorithms (iterative variable subset optimization (IVSO), variable combination population analysis- iteratively retaining informative variables (VCPA-IRIV), bootstrapping soft shrinkage (BOSS), and principal component analysis (PCA)) were used to optimize the NIR spectrum and extract spectral data. Partial least squares (PLS) linear regression and a nonlinear model (convolutional neural network–bi-directional long short-term memory (CNN-BiLSTM)) were used to establish and compare 52 quantitative prediction models. The optimum prediction model was the SG-IVSO-PLS-CNN-BiLSTM. Its correlation coefficient of prediction (Rp), root mean square error of prediction (RMSEP), and relative percent deviation (RPD) were 0.949, 1.350 %, and 3.172 for predicting the moisture content and 0.937, 1.110 %, and 2.863 for predicting the starch content. The SG-IVSO-PLS-CNN-BiLSTM eliminated the influence of potato size and shape on the accuracy of the prediction model. This method is suitable for predicting potato quality in the potato processing industry.