daily pastebin goal
22%
SHARE
TWEET

Untitled

a guest Apr 17th, 2018 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.         static List<Tuple<int, double>> NearestNeighbours(int user, int k, double threshold, IDataSet data)
  2.         {
  3.             var userRated = data.Data[user].Keys;
  4.             var similarity = data.Data
  5.                 .Where(u => u.Key != user && u.Value.Keys.Except(userRated).Any())
  6.                 .Select(u => new Tuple<int, double>(u.Key, data.EuclideanSimilarity(user, u.Key)))
  7.                 .Where(u => u.Item2 >= threshold)
  8.                 .OrderByDescending(x => x.Item2)
  9.                 .Take(k)
  10.                 .ToList();
  11.             return similarity;
  12.         }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top