protected override FastIDSet doGetCandidateItems(long[] preferredItemIDs, IDataModel dataModel) {
   FastIDSet candidateItemIDs = new FastIDSet();
   foreach (long itemID in preferredItemIDs) {
     candidateItemIDs.AddAll(similarity.AllSimilarItemIDs(itemID));
   }
   candidateItemIDs.RemoveAll(preferredItemIDs);
   return candidateItemIDs;
 }
 protected override FastIDSet doGetCandidateItems(long[] preferredItemIDs, IDataModel dataModel) {
   FastIDSet possibleItemIDs = new FastIDSet(dataModel.GetNumItems());
   var allItemIDs = dataModel.GetItemIDs();
   while (allItemIDs.MoveNext()) {
     possibleItemIDs.Add(allItemIDs.Current);
   }
   possibleItemIDs.RemoveAll(preferredItemIDs);
   return possibleItemIDs;
 }
 protected FastIDSet getAllOtherItems(long[] theNeighborhood, long theUserID) {
   IDataModel dataModel = GetDataModel();
   FastIDSet possibleItemIDs = new FastIDSet();
   foreach (long userID in theNeighborhood) {
     possibleItemIDs.AddAll(dataModel.GetItemIDsFromUser(userID));
   }
   possibleItemIDs.RemoveAll(dataModel.GetItemIDsFromUser(theUserID));
   return possibleItemIDs;
 }
Пример #4
0
        protected override FastIDSet doGetCandidateItems(long[] preferredItemIDs, IDataModel dataModel)
        {
            FastIDSet candidateItemIDs = new FastIDSet();

            foreach (long itemID in preferredItemIDs)
            {
                candidateItemIDs.AddAll(similarity.AllSimilarItemIDs(itemID));
            }
            candidateItemIDs.RemoveAll(preferredItemIDs);
            return(candidateItemIDs);
        }
 protected override FastIDSet doGetCandidateItems(long[] preferredItemIDs, IDataModel dataModel) {
   FastIDSet possibleItemsIDs = new FastIDSet();
   foreach (long itemID in preferredItemIDs) {
     IPreferenceArray itemPreferences = dataModel.GetPreferencesForItem(itemID);
     int numUsersPreferringItem = itemPreferences.Length();
     for (int index = 0; index < numUsersPreferringItem; index++) {
       possibleItemsIDs.AddAll(dataModel.GetItemIDsFromUser(itemPreferences.GetUserID(index)));
     }
   }
   possibleItemsIDs.RemoveAll(preferredItemIDs);
   return possibleItemsIDs;
 }
        protected override FastIDSet doGetCandidateItems(long[] preferredItemIDs, IDataModel dataModel)
        {
            FastIDSet possibleItemIDs = new FastIDSet(dataModel.GetNumItems());
            var       allItemIDs      = dataModel.GetItemIDs();

            while (allItemIDs.MoveNext())
            {
                possibleItemIDs.Add(allItemIDs.Current);
            }
            possibleItemIDs.RemoveAll(preferredItemIDs);
            return(possibleItemIDs);
        }
Пример #7
0
        protected FastIDSet getAllOtherItems(long[] theNeighborhood, long theUserID)
        {
            IDataModel dataModel       = GetDataModel();
            FastIDSet  possibleItemIDs = new FastIDSet();

            foreach (long userID in theNeighborhood)
            {
                possibleItemIDs.AddAll(dataModel.GetItemIDsFromUser(userID));
            }
            possibleItemIDs.RemoveAll(dataModel.GetItemIDsFromUser(theUserID));
            return(possibleItemIDs);
        }
        protected override FastIDSet doGetCandidateItems(long[] preferredItemIDs, IDataModel dataModel)
        {
            FastIDSet possibleItemsIDs = new FastIDSet();

            foreach (long itemID in preferredItemIDs)
            {
                IPreferenceArray itemPreferences = dataModel.GetPreferencesForItem(itemID);
                int numUsersPreferringItem       = itemPreferences.Length();
                for (int index = 0; index < numUsersPreferringItem; index++)
                {
                    possibleItemsIDs.AddAll(dataModel.GetItemIDsFromUser(itemPreferences.GetUserID(index)));
                }
            }
            possibleItemsIDs.RemoveAll(preferredItemIDs);
            return(possibleItemsIDs);
        }
Пример #9
0
        protected override FastIDSet doGetCandidateItems(long[] preferredItemIDs, IDataModel dataModel)
        {
            var preferredItemIDsIterator = ((IEnumerable <long>)preferredItemIDs).GetEnumerator();

            if (preferredItemIDs.Length > maxItems)
            {
                double samplingRate = (double)maxItems / preferredItemIDs.Length;
                log.Info("preferredItemIDs.Length {0}, samplingRate {1}", preferredItemIDs.Length, samplingRate);
                preferredItemIDsIterator =
                    new SamplinglongPrimitiveIterator(preferredItemIDsIterator, samplingRate);
            }
            FastIDSet possibleItemsIDs = new FastIDSet();

            while (preferredItemIDsIterator.MoveNext())
            {
                long             itemID = preferredItemIDsIterator.Current;
                IPreferenceArray prefs  = dataModel.GetPreferencesForItem(itemID);
                int prefsLength         = prefs.Length();
                if (prefsLength > maxUsersPerItem)
                {
                    var sampledPrefs =
                        new FixedSizeSamplingIterator <IPreference>(maxUsersPerItem, prefs.GetEnumerator());
                    while (sampledPrefs.MoveNext())
                    {
                        addSomeOf(possibleItemsIDs, dataModel.GetItemIDsFromUser(sampledPrefs.Current.GetUserID()));
                    }
                }
                else
                {
                    for (int i = 0; i < prefsLength; i++)
                    {
                        addSomeOf(possibleItemsIDs, dataModel.GetItemIDsFromUser(prefs.GetUserID(i)));
                    }
                }
            }
            possibleItemsIDs.RemoveAll(preferredItemIDs);
            return(possibleItemsIDs);
        }
  protected override FastIDSet doGetCandidateItems(long[] preferredItemIDs, IDataModel dataModel) {
    var preferredItemIDsIterator = ((IEnumerable<long>)preferredItemIDs).GetEnumerator();
    if (preferredItemIDs.Length > maxItems) {
      double samplingRate = (double) maxItems / preferredItemIDs.Length;
      log.Info("preferredItemIDs.Length {0}, samplingRate {1}", preferredItemIDs.Length, samplingRate);
      preferredItemIDsIterator = 
          new SamplinglongPrimitiveIterator(preferredItemIDsIterator, samplingRate);
    }
    FastIDSet possibleItemsIDs = new FastIDSet();
    while (preferredItemIDsIterator.MoveNext()) {
      long itemID = preferredItemIDsIterator.Current;
      IPreferenceArray prefs = dataModel.GetPreferencesForItem(itemID);
      int prefsLength = prefs.Length();
	  if (prefsLength > maxUsersPerItem) {
        var sampledPrefs =
			new FixedSizeSamplingIterator<IPreference>(maxUsersPerItem, prefs.GetEnumerator());
        while (sampledPrefs.MoveNext()) {
          addSomeOf(possibleItemsIDs, dataModel.GetItemIDsFromUser(sampledPrefs.Current.GetUserID()));
        }
      } else {
        for (int i = 0; i < prefsLength; i++) {
          addSomeOf(possibleItemsIDs, dataModel.GetItemIDsFromUser(prefs.GetUserID(i)));
        }
      }
    }
    possibleItemsIDs.RemoveAll(preferredItemIDs);
    return possibleItemsIDs;
  }