The subjective and empirical setting of hyperparameters in the random forest (RF) model may lead to decreased model performance. To address this, our study applies the particle swarm optimization (PSO) algorithm to select the optimal parameters of the RF model, with the goal of enhancing model performance. We employ the optimized ensemble model (PSO-RF) to create a fire risk map for Jiushan National Forest Park in Anhui Province, China, thereby filling the research gap in this region’s forest fire studies. Based on collinearity tests and previous research results, we selected eight fire driving factors, including topography, climate, human activities, and vegetation for modeling. Additionally, we compare the logistic regression (LR), support vector machine (SVM), and RF models. Lastly, we select the optimal model to evaluate feature importance and generate the fire risk map. Model evaluation results demonstrate that the PSO-RF model performs best (AUC = 0.908), followed by RF (0.877), SVM (0.876), and LR (0.846). In the fire risk map created by the PSO-RF model, 70.73% of the area belongs to the normal management zone, while 15.23% is classified as a fire alert zone. The feature importance analysis of the PSO-RF model reveals that the NDVI is the key fire driving factor in this study area. Through utilizing the PSO algorithm to optimize the RF model, we have addressed the subjective and empirical problems of the RF model hyperparameter setting, thereby enhancing the model’s accuracy and generalization ability.