Market economy is characterized by the uncertainty of supply and demand, so enterprises can realize the optimization of inventory cost control only by reasonably forecasting the demand of supply chain. This paper studies a supply chain demand forecasting method based on machine learning. The factors affecting supply chain demand are collected and analyzed, and the ARMA model, which combines autoregressive model and moving average model, is used to forecast supply chain demand. Then, through the introduction of procurement cost, storage cost and time cost, a multi-level inventory model is established, and the immune genetic algorithm is used to solve the model to find the optimal inventory cost. The experimental results show that the prediction model has good forecasting performance. After using the optimized scheme, the total inventory cost of the enterprise supply chain is reduced by 17.35% and 13.69% respectively. It can be seen that, on the whole, the method in this paper has a good effect of supply chain demand forecasting and cost control.