The objective of the coal blending optimization problem is to find an optimal coal blending in the feasible domain such that the blended coal meets the quality requirements at the end of the coking process and the cost of coal blending is minimized. This paper proposes a hybrid residual prediction model and an improved genetic algorithm to solve this problem and predict coke quality. For this purpose, a hybrid residual prediction model is used to predict coke quality. The model first uses a random forest feature extraction method to reduce the dimensionality of the data, and then trains several prediction models such as eXtreme Gradient Boosting (XGBoost), Adaboost and Light Gradient-Boosting Machine (lightGBM) for different coke indicators an improved genetic algorithm based on the adaptive weighted genetic algorithm (awGA) and another improved genetic algorithm based on a priori knowledge and adaptive random initialization method were designed and implemented to solve the optimization problem under strict constraints (P-awGA). The experimental results show that using the hybrid residual prediction model and the improved genetic algorithm can accurately predict the coke quality and use less time to obtain a lower-cost coal blending solution.