Energy is the main driving force for economic and social development. While a reliable prediction of a country's primary energy consumption (PEC) is paramount, it remains a daunting task because many factors in various sectors of society affect the primary energy consumption in complex nonlinear ways. Based on China's energy statistics from 1952 to 2019, 25 influencing factors are considered from five dimensions of economy, energy, environment, technology and policy, and the correlation analysis method is used to evaluate the relationship between the primary energy consumption and each influencing factor. In addition, multicollinearity of variables is diagnosed by R program. Multiple linear regression (MLR) and artificial neural networks (ANN) model are applied to fit PEC curve. The discriminatory machine learning algorithms are compared and analyzed. The results show that the MLR model has the advanced of fitting compared with ANN in small sample data. Moreover, forward selection (FS), backward elimination (BE), forced introduction (FI) and ridge regression (RR) are used to obtain the fitting equation of the PEC. The mean absolute percentage errors (MAPE) of FS, BE, FI, RR and ANN are 2.16%, 1.68%, 1.91%, 1.31% and 19.89%, respectively. Finally, scenario analysis is used to predict China's PEC in 2050.