Purpose This study develops and evaluates a data-driven forecasting framework for freight railway traffic along Morocco's Tanger–Casablanca corridor, with the objective of assessing whether advanced machine learning models can enhance the accuracy and robustness of medium-term demand forecasting compared to conventional statistical time-series methods, thereby improving both operational railway planning and strategic logistics decision-making. Design/methodology/approach A quantitative research design is employed using sixteen weeks of aggregated data derived from 2,159 operational records collected along the Tanger–Casablanca railway corridor. The dataset integrates multiple sources, including railway operational indicators, port throughput measures, industrial production indices, and macroeconomic variables. The study implements classical statistical models (ARIMA and SARIMA) alongside machine learning approaches, namely Random Forest, Gradient Boosting, Long Short-Term Memory (LSTM), and Prophet. Rigorous preprocessing, feature engineering, rolling-window validation, and multi-metric evaluation (MAE, RMSE, MAPE, and R2) are applied to ensure robust and unbiased model comparison. Findings The results indicate that machine learning approaches consistently outperform traditional statistical models in forecasting freight railway demand. Among all models, LSTM delivers the highest predictive accuracy, followed by Gradient Boosting and Random Forest, while ARIMA and SARIMA serve as baseline benchmarks but show reduced performance during periods of peak demand. The analysis further reveals that port throughput and wagon allocation are the most significant predictors of freight volume, confirming the presence of nonlinear and temporally dependent demand structures that are more effectively captured by advanced learning models. Originality/value This study contributes to the limited empirical literature on railway freight forecasting in developing countries by applying and systematically comparing advanced machine learning techniques within the Moroccan railway context. It introduces an integrated forecasting framework that combines heterogeneous data sources with rigorous validation procedures, thereby bridging the gap between predictive analytics and operational railway decision-making. The proposed approach offers both methodological innovation and practical insights to support the modernization of rail freight systems in emerging logistics environments.
Moussaoui et al. (Fri,) studied this question.