PlusAnonymousConcurrentUserDataModel ClassNReco.Recommender Class Library

This is a special thread-safe version of PlusAnonymousUserDataModel which allow multiple concurrent anonymous requests.

To use it, you have to estimate the number of concurrent anonymous users of your application. The pool of users with the given size will be created. For each anonymous recommendations request, a user has to be taken from the pool and returned back immediately afterwards.

If no more users are available in the pool, anonymous recommendations cannot be produced.

Inheritance Hierarchy

System.Object
  NReco.CF.Taste.Impl.Model.PlusAnonymousUserDataModel
    NReco.CF.Taste.Impl.Model.PlusAnonymousConcurrentUserDataModel

Namespace: NReco.CF.Taste.Impl.Model
Assembly: NReco.Recommender (in NReco.Recommender.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax

public sealed class PlusAnonymousConcurrentUserDataModel : PlusAnonymousUserDataModel

The PlusAnonymousConcurrentUserDataModel type exposes the following members.

Constructors

  NameDescription
Public methodPlusAnonymousConcurrentUserDataModel
Initializes a new instance of the PlusAnonymousConcurrentUserDataModel class
Top
Methods

  NameDescription
Public methodclearTempPrefs (Inherited from PlusAnonymousUserDataModel.)
Public methodClearTempPrefs
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetItemIDs (Inherited from PlusAnonymousUserDataModel.)
Public methodGetItemIDsFromUser (Overrides PlusAnonymousUserDataModel.GetItemIDsFromUser(Int64).)
Public methodGetMaxPreference (Inherited from PlusAnonymousUserDataModel.)
Public methodGetMinPreference (Inherited from PlusAnonymousUserDataModel.)
Public methodGetNumItems (Inherited from PlusAnonymousUserDataModel.)
Public methodGetNumUsers (Overrides PlusAnonymousUserDataModel.GetNumUsers().)
Public methodGetNumUsersWithPreferenceFor(Int64) (Overrides PlusAnonymousUserDataModel.GetNumUsersWithPreferenceFor(Int64).)
Public methodGetNumUsersWithPreferenceFor(Int64, Int64) (Overrides PlusAnonymousUserDataModel.GetNumUsersWithPreferenceFor(Int64, Int64).)
Public methodGetPreferencesForItem (Overrides PlusAnonymousUserDataModel.GetPreferencesForItem(Int64).)
Public methodGetPreferencesFromUser (Overrides PlusAnonymousUserDataModel.GetPreferencesFromUser(Int64).)
Public methodGetPreferenceTime (Overrides PlusAnonymousUserDataModel.GetPreferenceTime(Int64, Int64).)
Public methodGetPreferenceValue (Overrides PlusAnonymousUserDataModel.GetPreferenceValue(Int64, Int64).)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodGetUserIDs (Overrides PlusAnonymousUserDataModel.GetUserIDs().)
Public methodHasPreferenceValues (Inherited from PlusAnonymousUserDataModel.)
Public methodRefresh (Inherited from PlusAnonymousUserDataModel.)
Public methodReleaseUser
Public methodRemovePreference (Overrides PlusAnonymousUserDataModel.RemovePreference(Int64, Int64).)
Public methodSetPreference (Overrides PlusAnonymousUserDataModel.SetPreference(Int64, Int64, Single).)
Public methodSetTempPrefs(IPreferenceArray) (Inherited from PlusAnonymousUserDataModel.)
Public methodSetTempPrefs(IPreferenceArray, Int64)
Public methodTakeAvailableUser
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Examples

Setup:
int concurrentUsers = 100;
IDataModel realModel = ..
PlusAnonymousConcurrentUserDataModel plusModel =
  new PlusAnonymousConcurrentUserDataModel(realModel, concurrentUsers);
IRecommender recommender = ...;
PlusAnonymousConcurrentUserDataModel plusModel =
  (PlusAnonymousConcurrentUserDataModel) recommender.GetDataModel();

// Take the next available anonymous user from the pool 
long anonymousUserID = plusModel.TakeAvailableUser();

IPreferenceArray tempPrefs = ..
tempPrefs.SetUserID(0, anonymousUserID);
tempPrefs.SetItemID(0, itemID);
plusModel.SetTempPrefs(tempPrefs, anonymousUserID);

// Produce recommendations
recommender.Recommend(anonymousUserID, howMany);

// It is very IMPORTANT to release user back to the pool
plusModel.ReleaseUser(anonymousUserID);
Real-time recommendation:
See Also