We are now going to build, compile, and train our model using our user-item ratings data. Specifically, we will use Keras to construct a customized neural network with embedded layers (one for users and one for items) and a lambda function that computes the dot product to build a working prototype of a neural network-based recommender system:
- Let's get started using the following code:
# create custom model with user and item embeddings
dot <- function(
embedding_dim,
n_users,
n_items,
name = "dot"
) {
keras_model_custom(name = name, function(self) {
self$user_embedding <- layer_embedding(
input_dim = n_users+1,
output_dim = embedding_dim,
name = "user_embedding")
self$item_embedding <- layer_embedding(
input_dim = n_items+1,
output_dim = embedding_dim...