Skip to content

Commit

Permalink
update stats for users having highest vs items having lowest statistics
Browse files Browse the repository at this point in the history
  • Loading branch information
Thanh Doan committed Apr 17, 2011
1 parent b5b7c99 commit 4db38f5
Showing 1 changed file with 37 additions and 24 deletions.
61 changes: 37 additions & 24 deletions codes/k_user_stats.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,40 @@
load users.mat;
end

num_user_ratings = users(:,1);
[~, p] = sort(num_user_ratings);

n = size(p,1);
most_active_idx = p(n-k+1:n);
least_active_idx = p(1:k);
rand_user_idx = randi(nUsers,k,1);

most_active_users = [most_active_idx, users(most_active_idx,:)];
least_active_users = [least_active_idx, users(least_active_idx,:)];
random_users = [rand_user_idx, users(rand_user_idx,:)];

most_active_stats = dataset({most_active_users, 'user_id', 'number_ratings', 'mean', 'user_bias', 'std', 'min', 'max', 'median', 'mode'});
fprintf('%d users having highest number of ratings : \n', k);
fprintf('These users have susceptive biases and influence predicted ratings???? : \n');
disp(most_active_stats);

least_active_stats = dataset({least_active_users, 'user_id', 'num_ratings', 'mean', 'user_bias', 'std', 'min', 'max', 'median', 'mode'});
fprintf('%d users having lowest number of ratings : \n', k);
disp(least_active_stats);

rand_user_stats = dataset({random_users, 'user_id', 'num_ratings', 'mean', 'user_bias', 'std', 'min', 'max', 'median', 'mode'});
fprintf('%d random users : \n', k);
disp(rand_user_stats);
while (true)
disp('1) for stats about users havinng highest no of ratings');
disp('2) for stats about users havinng highest mean rating');
disp('3) for stats about users havinng highest rating bias');
disp('4) for stats about users havinng highest rating variance ');
disp('-1) for exit');

option_id = input('Enter option id: ');
if option_id == -1
break;
end

my_user_ratings = abs(users(:,option_id));
[~, p] = sort(my_user_ratings);

n = size(p,1);
most_active_idx = p(n-k+1:n);
least_active_idx = p(1:k);
rand_user_idx = randi(nUsers,k,1);

most_active_users = [most_active_idx, users(most_active_idx,:)];
least_active_users = [least_active_idx, users(least_active_idx,:)];
random_users = [rand_user_idx, users(rand_user_idx,:)];

most_active_stats = dataset({most_active_users, 'user_id', 'number_ratings', 'mean', 'user_bias', 'std', 'min', 'max', 'median', 'mode'});
fprintf('%d users having highest: \n', k);
fprintf('These users have susceptive biases and influence predicted ratings???? : \n');
disp(most_active_stats);

least_active_stats = dataset({least_active_users, 'user_id', 'num_ratings', 'mean', 'user_bias', 'std', 'min', 'max', 'median', 'mode'});
fprintf('%d users having lowest: \n', k);
disp(least_active_stats);

rand_user_stats = dataset({random_users, 'user_id', 'num_ratings', 'mean', 'user_bias', 'std', 'min', 'max', 'median', 'mode'});
fprintf('%d random users : \n', k);
disp(rand_user_stats);
end

0 comments on commit 4db38f5

Please sign in to comment.