A class correlation distance collaborative filtering recommendation algorithm is proposed to solve the problems of category judgment and distance metric in the traditional collaborative filtering recommendation algorithm, which is using the advantage of the distance between the same samples and the class related distance. First, the class correlation distance between the training samples is calculated and stored. Second, the K nearest neighbor samples are selected, the class correlation distance of training samples and the difference ratio between the test samples and training samples are calculated respectively. Finally, according to the difference ratio, we classify the different types of samples. The experimental result shows that the algorithm combined with user rating preference can get lower MAE value, and the recommendation effect is better. With the change of K value, CCDKNN algorithm is obviously better than KNN algorithm and DWKNN algorithm, and the accuracy performance is more stable. The algorithm improves the accuracy of similarity and predictability, which has better performance than the traditional algorithm.