PSO algorithm with stochastic inertia weight has better converging speed and ability than the basic PSO algorithm. The PSO algorithm with stochastic inertia is analyzed, and is applied to the clustering algorithm. The data sets of UCI data collection are used to experiment, the results of the experiment shows that the new clustering algorithm is better than K-means algorithm in quantization error, and the result of clustering is not affected by the size of the particle swarm. The application in instruction websites of the new clustering algorithm is discussed.