Power transformers are essential components in power systems used to regulate voltage, transmit electrical energy, provide isolation, and match loads. They contribute to efficient and reliable electricity transmission and distribution. However, traditional methods for diagnosing transformer faults are time-consuming, not suitable for online monitoring, and greatly affected by environmental conditions. In this experiment, we propose the use of laser-induced fluorescence (LIF) technology for transformer fault detection. LIF technology is a method for analyzing and detecting specific molecules or atoms in samples. It combines laser technology with fluorescence measurements, making it a powerful analytical tool. It achieves high sensitivity and selectivity in analyzing molecules and atoms by exciting and detecting fluorescence in the sample. This makes it an important technology in scientific research and practical applications. Furthermore, LIF technology has not been previously applied to power transformer fault diagnosis. Therefore, this experiment introduces a transformer fault diagnosis model based on the marine predators algorithm (MPA) optimized random forest (RF) algorithm and LIF spectroscopy technology. Four different oil samples were selected for experimentation: crude oil, thermally faulty oil, partially moist oil, and electrically faulty oil. First, LIF technology for collect spectral images and data from the different fault oil samples. The obtained spectral data was preprocessed using two methods, multivariate scatter correction (MSC) and standardization method (SNV). Then, principal component analysis (PCA) and kernel principal component analysis (KPCA) for reducing the dimensionality of the preprocessed spectral data. Finally, the RF model, MPA-RF model, and PSO-RF model were established; and the reduced data was input into the model for training. Through comparisons of the predictions on the test set, evaluation metrics of the algorithm (including fitting coefficient, MSE, RMSE, and RMSE), and iteration convergence curves, the best transformer fault diagnosis model was identified. The results show that the MSC-KPCA-MPA-RF model has the best matching resule, with a fitting coefficient of 0.9963 and a mean square error of 0.0047. The SNV-PCA-MPA-RF model has the worst fitting effect, with a fitting coefficient of 0.9840 and a mean square error of 0.0199. Through comparisons of the convergence of different models, the MSC-KPCA-MPA-RF model has the best convergence and is the most applicable model for transformer fault diagnosis in this experiment. This model has significant implications for ensuring the safety of the power system.