The impact parameter is one of the crucial physical quantities of heavy-ion collisions (HICs), and can affect obviously many observables at the final state, such as the multifragmentation and the collective flow. Usually, it cannot be measured directly in experiments but might be inferred from observables at the final state. Artificial intelligence has had great success in learning complex representations of data, which enables novel modeling and data processing approaches in physical sciences. In this article, we employ two of commonly used algorithms in the field of artificial intelligence, the Convolutional Neural Networks (CNN) and Light Gradient Boosting Machine (LightGBM), to improve the accuracy of determining impact parameter by analyzing the proton spectra in transverse momentum and rapidity on the event-by-event basis. Au+Au collisions with the impact parameter of 0≤b≤10 fm at intermediate energies (E lab =0.2-1.0 GeV/nucleon) are simulated with the ultrarelativistic quantum molecular dynamics (UrQMD) model to generate the proton spectra data. It is found that the average difference between the true impact parameter and the estimated one can be smaller than 0.1 fm. The LightGBM algorithm shows an improved performance with respect to the CNN on the task in this work. By using the LightGBM's visualization algorithm, one can obtain the important feature map of the distribution of transverse momentum and rapidity, which may be helpful in inferring the impact parameter or centrality in heavy-ion experiments.