绘制评级矩阵
计算科学
matlab
Python
矩阵
稀疏矩阵
matplotlib
2021-12-18 10:52:37
1个回答
我能够以这种方式做到这一点,尽管按照 Federico 之前提到的方式绘制它可能更容易:imagesc(A)。
我声明了一个mxn 维度的零矩阵,然后加载了评级。然后我应用了 HeatMap(A),它产生了下面的图像。
A = importdata('u.data');
user_id = A(:, 1);
movie_id = A(:, 2);
rating = A(:, 3);
% Build matrix R
R = zeros(943, 1682);
for i=1:100000
R(user_id(i), movie_id(i)) = rating(i);
end
m = HeatMap(R,’Xlabel’,’I did it!’)
ax = hm.plot; % 'ax' will be a handle to a standard MATLAB axes.
colorbar('Peer', ax); % Turn the colorbar on
caxis(ax, [0 5]); % Adjust the color limits
其它你可能感兴趣的问题