Batteries as a power source for electric trains have been considered due to a number of advantages, including flexibility, reduced air and noise pollution, and lower operating costs. Estimating the lifespan of batteries is one of the most basic challenges to evaluating their economic efficiency. This article presents a helpful life forecast of lithium-ion batteries in electric trains, utilizing the Adaptive Neuro-Fuzzy Inference System (ANFIS) to determine replacement time and economic efficiency. To assess battery performance in electric trains, the train dynamic model is simulated for one motion cycle. In this simulation, the speed profile of the train is considered to be constant and repeated, and then, by applying the current consumption of the train to the battery, the battery's life is predicted for a limited length of time using machine learning (ML) models. In the test stage, comparing the ANFIS model to other ML methods indicates that it outperforms all error indicators and has a higher accuracy for estimating battery life.