Resource-rich shale gas plays a pivotal role in new energy types. The key to scientifically and efficiently developing shale gas fields is to clarify the main factors that affect the production of shale gas wells. In this paper, according to the shale gas reservoir characteristic of the Fuling marine Longmaxi Formation, a single-well geological model was established using the reservoir numerical simulation software CMG. Then, 10,000 different reservoir models were randomly generated for different formation physical parameters, completion parameters, and fracturing parameters using the Monte Carlo method, and these 10,000 models were simulated numerically. The machine learning model uses a dataset of 10,000 different geological, completion, and fracturing parameters as input and 10,000 production curves as output. Multiple machine learning regression methods were used to train and test the dataset, and the optimal method (GBDT algorithm) was selected, and the accuracy R2 of the test set of the GBDT prediction model is 0.96. A fracturing parameter optimization workflow was constructed by combining a production prediction model with a particle swarm optimizer (PSO). The process can quickly optimize the fracturing parameters and predict the production for each time by targeting the cumulative gas production under different geological conditions. The optimized parameters are Fracture Spacing, Fracture Width, Intrinsic Permeability, Fracture Half-length, Langmuir Pressure, and Langmuir Volume. The initial predicted cumulative gas production was 4.59 × 108 m3, which was optimized to 4.90 × 108 m3. The proposed PSO-GBDT proxy model can instantly predict the production of shale gas wells with considerable accuracy, reliability, and efficiency, which is a vital tool for optimizing fracture design. This investigation provides a solid foundation for predicting the production of unconventional gas reservoirs and for parameter optimization.