BPR

class openrec.recommenders.BPR(batch_size, max_user, max_item, dim_embed, test_batch_size=None, l2_reg=None, opt='SGD', lr=None, init_dict=None, sess_config=None)[source]

Pure Baysian Personalized Ranking (BPR) [1] based Recommender

Parameters:
  • batch_size (int) – Training batch size. Each training instance consists of an user, a positive item, and a negative item.
  • max_user (int) – Maximum number of users in the recommendation system.
  • max_item (int) – Maximum number of items in the recommendation system.
  • dim_embed (int) – Dimensionality of the user/item embedding.
  • test_batch_size (int, optional) – Batch size for testing and serving. Each testing/serving bacth consists of an user.
  • l2_reg (float, optional) – Weight for L2 regularization, i.e., weight decay.
  • opt ('SGD'(default) or 'Adam', optional) – Optimization algorithm, SGD: Stochastic Gradient Descent.
  • lr (float, optional) – Initial learning rate.
  • init_dict (dict, optional) – Key-value pairs for inital parameter values.
  • sess_config (tensorflow.ConfigProto(), optional) – Tensorflow session configuration.

Notes

BPR recommender is trained on users’ implicit feedback signals (e.g., clicks and views). The items clicked or viewed are treated as positive items, and otherwise as negative items. The pure BPR recommender does not consider any other auxiliary signals.

References

[1]Rendle, S., Freudenthaler, C., Gantner, Z. and Schmidt-Thieme, L., 2009, June. BPR: Bayesian personalized ranking from implicit feedback. In Proceedings of the twenty-fifth conference on uncertainty in artificial intelligence (pp. 452-461). AUAI Press.
_build_default_interactions(train=True)[source]

Build default interaction modules (may be overriden).

Parameters:train (bool) – An indicator for training or servining phase.
_build_item_extractions(train=True)[source]

Build extraction modules for items’ data sources (should be overriden)

Parameters:train (bool) – An indicator for training or servining phase.
_build_item_inputs(train=True)[source]

Build inputs for items’ data sources (should be overriden)

Parameters:train (bool) – An indicator for training or servining phase.
_build_serving_graph()[source]

Call sub-functions to build serving graph (do NOT override).

_build_user_extractions(train=True)[source]

Build extraction modules for users’ data sources (should be overriden)

Parameters:train (bool) – An indicator for training or servining phase.
_build_user_inputs(train=True)[source]

Build inputs for users’ data sources (should be overriden)

Parameters:train (bool) – An indicator for training or servining phase.
_input_mappings(batch_data, train)[source]

Define mappings from input training batch to defined inputs.

Parameters:
  • batch_data (dict) – A training batch.
  • train (bool) – An indicator for training or servining phase.
Returns:

The mapping where a key corresponds to an input object, and a value corresponds to a batch_data value.

Return type:

dict