Collaborative Filtering

for i=1:6040
Ai=ratings(ratings(:,1)==i,:);
for j=1:5
Labnum(i,j)=length(Ai(Ai(:,3)==j));
end
num(i)=length(Ai(:,1));
end

num=[[1:6040]',num'];
numsort=sortrows(num,-2);

  

Xratings1101_1500=[];
for i=1:1501
Xratings1101_1500=[Xratings1101_1500;ratingsNew1101_518(ratingsNew1101_518(:,1)==numsort1101(i,1),:)];
end

  

items1101_518=ratings(ratings(:,1)==1101,2);
ratings1101_518=[];
for i=1:518
items=items1101_518(i);
ratings1101_518=[ratings1101_518;ratings(ratings(:,1)==items,:)];
end
users1101_518 = unique(ratings1101_518(:,1)'); 

  

items1101_518=ratings(ratings(:,1)==1101,2);
ratings1101_518=[];
for i=1:518
items=items1101_518(i);
ratings1101_518=[ratings1101_518;ratings(ratings(:,2)==items,:)];
end
items1101_518=sortrows(items1101_518,1); ratingsNew1101_518=ratings1101_518;
for i=1:518
ratingsNew1101_518(ratingsNew1101_518(:,2)==items1101_518(i),2)=i;
end
ratingsNew1101_518=sortrows(ratingsNew1101_518,2);

  

Xratings1101_1500=[];
for i=1:1501
Xi=ratings1101_518(ratings1101_518(:,1)==numsort1101(i,1),:);
Xi(:,1)=i;
Xratings1101_1500=[Xratings1101_1500;Xi];
end

 

Xratings1101_1500=[];
for i=1:1501
Xi=ratingsNew1101_518(ratingsNew1101_518(:,1)==numsort1101(i,1),:);
Xi(:,1)=i;
Xratings1101_1500=[Xratings1101_1500;Xi];
end

  

 

X1101=zeros(1501,518);
>> for i=1:size(Xratings1101_1500,1)
X1101(Xratings1101_1500(i,1),Xratings1101_1500(i,2)) = Xratings1101_1500(i,3);
end

  

上一篇:Grunt 初体验


下一篇:点击按钮文字变成input框,点击保存变成文字