PlusAnonymousUserDataModel ClassNReco.Recommender Class Library

This IDataModel decorator class is useful in a situation where you wish to recommend to a user that doesn't really exist yet in your actual IDataModel. For example maybe you wish to recommend DVDs to a user who has browsed a few titles on your DVD store site, but, the user is not yet registered.

This enables you to temporarily add a temporary user to an existing IDataModel in a way that recommenders can then produce recommendations anyway.

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 class PlusAnonymousUserDataModel : IDataModel, 
	IRefreshable

The PlusAnonymousUserDataModel type exposes the following members.

Constructors

  NameDescription
Public methodPlusAnonymousUserDataModel
Initializes a new instance of the PlusAnonymousUserDataModel class
Top
Methods

  NameDescription
Public methodclearTempPrefs
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Protected methodgetDelegate
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetItemIDs
Public methodGetItemIDsFromUser
Public methodGetMaxPreference
Public methodGetMinPreference
Public methodGetNumItems
Public methodGetNumUsers
Public methodGetNumUsersWithPreferenceFor(Int64)
Public methodGetNumUsersWithPreferenceFor(Int64, Int64)
Public methodGetPreferencesForItem
Public methodGetPreferencesFromUser
Public methodGetPreferenceTime
Public methodGetPreferenceValue
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodGetUserIDs
Public methodHasPreferenceValues
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodRefresh
Public methodRemovePreference
Public methodSetPreference
Public methodSetTempPrefs
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Fields

  NameDescription
Public fieldStatic memberTEMP_USER_ID
Top
Examples

IDataModel realModel = ...;
IDataModel plusModel = new PlusAnonymousUserDataModel(realModel);
...
var similarity = new LogLikelihoodSimilarity(realModel); // not plusModel

But, you may continue to use

as input to other components. To recommend, first construct and set the temporary user information on the model and then simply call the recommender. The block exists to remind you that this is of course not thread-safe. Only one set of temp data can be inserted into the model and used at one time.

IRecommender recommender = ...;
...
lock(...) {
  IPreferenceArray tempPrefs = ...;
  plusModel.SetTempPrefs(tempPrefs);
  recommender.Recommend(PlusAnonymousUserDataModel.TEMP_USER_ID, 10);
  plusModel.SetTempPrefs(null);
}
See Also