With the development of national economy, people's consumption level has also increased. In order to improve the utilization rate of products, reduce waste, and meet the requirements of environmental protection, it is necessary to improve the commodity sales forecast to reduce the waste of resources. Therefore, this paper proposes the role of machine learning algorithm in commodity sales forecasting. This paper mainly uses the cluster analysis method and the comparison method to carry on the experiment and the data analysis to the commodity sales volume forecast system. The experimental results show that the response time of the system designed in this paper is less than 2s, which can well meet the system requirements. Therefore, machine learning has played a greater role in the prediction of commodity sales.