Due to the high degree of strong coupling and nonlinearity of marine lysozyme fermentation process, it is difficult to accurately model the mechanism. In order to achieve real‐time online measurement and effective control of bacterial concentration during fermentation, a generalized predictive control method based on least squares support vector machines is proposed. The particle swarm optimization least squares support vector machine (PSO‐LS‐SVM) model of lysozyme concentration is established by optimizing the regularization parameters and the kernel parameters of the least squares support vector machine by particle swarm optimization. To avoid the nonlinear problems in predictive control, the model is linearized at each sampling point and the generalized predictive algorithm is used to predict the bacteria concentration of lysozyme. The experimental simulation shows that the least squares support vector machine model with particle swarm optimization can achieve good prediction effect. The linearized model performs generalized predictive control, which makes the total activity of the enzyme increased from 60% to 80% and the yield improved by 30%.