In the collaborative filtering recommendation algorithm, sparse user rating data may result in inaccurate similarity calculation between users. To solve this problem, this paper proposes a method of filling unrated data on the user-item rating matrix by using linear regression model. Firstly, this method selects the average of user historical ratings and the average of item historical ratings as the features, selects the user's actual rating as the label, and trains the linear regression model of rating prediction for each user. Then, use the model to predict and fill the user's unrated data. Finally, use the traditional collaborative filtering algorithm for rating prediction on the filled user-item rating matrix. Experimental results show that the improved collaborative filtering recommendation algorithm can alleviate the data sparsity, find more reliable user neighbors, and improve the accuracy of rating prediction.