elliot.recommender.neural.NPR package

Submodules

elliot.recommender.neural.NPR.neural_personalized_ranking module

Module description:

class elliot.recommender.neural.NPR.neural_personalized_ranking.NPR(data, config, params, *args, **kwargs)[source]

Bases: elliot.recommender.recommender_utils_mixin.RecMixin, elliot.recommender.base_recommender_model.BaseRecommenderModel

Neural Personalized Ranking for Image Recommendation (Model without visual features)

For further details, please refer to the paper

Parameters
  • mf_factors – Number of MF latent factors

  • mlp_hidden_size – List of units for each layer

  • lr – Learning rate

  • l_w – Regularization coefficient

  • dropout – Dropout rate

To include the recommendation model, add it to the config file adopting the following pattern:

models:
  NPR:
    meta:
      save_recs: True
    epochs: 10
    batch_size: 512
    mf_factors: 100
    mlp_hidden_size:  (64,32)
    lr: 0.001
    l_w: 0.001
    dropout: 0.45
get_recommendations(k: int = 100)[source]
property name
train()[source]

elliot.recommender.neural.NPR.neural_personalized_ranking_model module

Module description:

class elliot.recommender.neural.NPR.neural_personalized_ranking_model.NPRModel(*args, **kwargs)[source]

Bases: tensorflow.python.keras.engine.training.Model

call(inputs, training=None, mask=None)[source]
get_recs(inputs, training=False, **kwargs)[source]

Get full predictions on the whole users/items matrix.

Returns

The matrix of predicted values.

get_top_k(preds, train_mask, k=100)[source]
predict(inputs, training=False, **kwargs)[source]

Get full predictions on the whole users/items matrix.

Returns

The matrix of predicted values.

train_step(batch)[source]

The logic for one training step.

This method can be overridden to support custom training logic. This method is called by Model.make_train_function.

This method should contain the mathemetical logic for one step of training. This typically includes the forward pass, loss calculation, backpropagation, and metric updates.

Configuration details for how this logic is run (e.g. tf.function and tf.distribute.Strategy settings), should be left to Model.make_train_function, which can also be overridden.

Parameters

data – A nested structure of `Tensor`s.

Returns

A dict containing values that will be passed to tf.keras.callbacks.CallbackList.on_train_batch_end. Typically, the values of the Model’s metrics are returned. Example: {‘loss’: 0.2, ‘accuracy’: 0.7}.

Module contents