One of the important concerns in the field of exercise immunology is determining the appropriate intensity and duration of exercise to prevent suppression of the immune system. Adopting a reliable approach to predict the number of white blood cells (WBCs) during exercise can help to identify the appropriate intensity and duration. Therefore, this study was designed to predict leukocyte levels during exercise with the application of a machine-learning model. We used a random forest (RF) model to predict the number of lymphocytes (LYMPH), neutrophils (NEU), monocytes (MON), eosinophils, basophils, and WBC. Intensity and duration of exercise, WBCs values before exercise training, body mass index (BMI), and maximal aerobic capacity (VO2max) were used as inputs and WBCs values after exercise training were assessed as outputs of the RF model. In this study, the data was collected from 200 eligible people and K-fold cross-validation was used to train and test the model. Finally, model efficiency was assessed using standard statistics (root mean square error (RMSE), mean absolute error (MAE), relative absolute error (RAE), root relative square error (RRSE), coefficient of determination (R2), and Nash–Sutcliffe efficiency coefficient (NSE)). Our findings revealed that the RF model performed well for predicting the number of WBC with RMSE = 0.94, MAE = 0.76, RAE = 48.54, RRSE = 48.17, NSE = 0.76, and R2= 0.77. Furthermore, the results showed that intensity and duration of exercise are more effective parameters than BMI and VO2max to predict the number of LYMPH, NEU, MON, and WBC during exercise. Totally, this study developed a novel approach based on the RF model using the relevant and accessible variables to predict WBCs during exercise. The proposed method can be applied as a promising and cost-effective tool for determining the correct intensity and duration of exercise in healthy people according to the body’s immune system response.