In the process of continuous development of e-commerce, to better meet the needs of users and tap the consumption potential of users, personalized recommendation systems have emerged on various e-commerce platforms. Although the clustering algorithm is suitable for solving the user segmentation problem, the traditional K-means algorithm has some shortcomings, such as the quality of the initial center point determined randomly is not high, and there is no definite criterion to select the value of K. Therefore, this paper proposes an optimized K-means algorithm, which uses the value of effectiveness index CH to determine the value of K, and combines with particle swarm algorithm to solve the initial center point. Experiments show that the optimization algorithm CH-PSO-K-means algorithm proposed in this paper has improved the DB index, accuracy rate, and error square index. The comprehensive performance of the clustering effect has been significantly improved, which can effectively solve the problem of e-commerce user segmentation with large data and multiple characteristics. The optimization algorithm not only makes up for the shortcomings of the K-means algorithm, but also improves the maintenance strategy of individual e-commerce users, which is conducive to enterprise cost control and profit improvement.