The invention discloses a clustering method, a system and a medium for automatically confirming the number of clusters based on a coefficient of variation, wherein, the density value of each data point in a data set is calculated, the density index is calculated according to the density value, and the data point with the largest density index is selected as a first clustering center; Calculating the shortest distance between each data point and the existing clustering center, calculating the probability that each data point is selected as the clustering center according to the shortest distance, and preselecting the clustering center according to the roulette disc method; Until the set cluster centers are selected, the initial cluster centers selected are used for k-means clustering to generate a corresponding number of clusters; Calculate the average intra-cluster coefficient of variation and the minimum inter-cluster coefficient of variation, then calculate the difference between theaverage intra-cluster coefficient of variation and the minimum inter-cluster coefficient of variation, compare the difference with the set value, and if the difference is less than the set value, merge the two clusters with the minimum inter-cluster coefficient of variation; Until the difference is greater than or equal to the set value, the clustering result is output.