NN Models
Models are in the src/models/
folder of the repository. For each model, there is a struct that is a subtype of NCFModel. The constructor ensures the proper folder_name
member parameter setting.
Generalized Matrix Factorization
NeuralCollaborativeFiltering.DotProductModel
— TypeDotProductModel(df_train, df_test, embeddings_size, flux_model)
Recommender system based on Generalized Matrix Factorization: 2 Embedding layers with a dot product. Sizes of both embedding layers depend on a number of movies and on a number of users respectively.
Fields
df_train::DataFrame
: Training set to be learnt on.df_test::DataFrame
: Testing set to be learnt on.emb_size::Int64
: Size of a single embedding vector for one user or for one movie.model::Chain
: Flux.jl Chain object representing the NN.folder_name::String
: Assigned todot_product_ncf
in the constructor automatically.
References
Multi Layer Perceptron
NeuralCollaborativeFiltering.MLPSimilarityModel
— TypeMLPSimilarityModel(df_train::DataFrame, df_test::DataFrame, emb_size::Int64, model::Chain)
Recommender system based on Multi Layer Perceptron: concatenate 2 Embedding layers and pass the result to the MLP. Sizes of both embedding layers depend on a number of movies and on a number of users respectively.
Fields
df_train::DataFrame
: Training set to be learnt on.df_test::DataFrame
: Testing set to be learnt on.emb_size::Int64
: Size of a single embedding vector for one user or for one movie.model::Chain
: Flux.jl Chain object representing the NN.folder_name::String
: Assigned tomlp_similarity_ncf
in the constructor automatically.
References
Combination of GMF and MLP similarity
NeuralCollaborativeFiltering.GMFAndMLPModel
— TypeGMFAndMLPModel(df_train::DataFrame, df_test::DataFrame, emb_size::Int64, model::Chain)
Recommender system based on a combination of Generalized Matrix Factorization and Multi Layer Perceptron similarity. Sizes of both embedding layers depend on a number of movies and on a number of users respectively.
Fields
df_train::DataFrame
: Training set to be learnt on.df_test::DataFrame
: Testing set to be learnt on.emb_size::Int64
: Size of a single embedding vector for one user or for one movie.model::Chain
: Flux.jl Chain object representing the NN.folder_name::String
: Assigned togmf_and_mlp_ncf
in the constructor automatically.
References
build_model() function
"Wrapper" function build_model()
uses Julia's multiple dispatch to create a neural network model based on the type of arguments:
NeuralCollaborativeFiltering.build_model
— Functionbuild_model(x::Type{DotProductModel}, df_train::DataFrame, df_test::DataFrame; embeddings_size=50, share_embeddings=nothing)
Constructs and returns an instance of DotProductModel using training and testing data sizes along with specified model parameters.
Arguments
x::Type{DotProductModel}
: The type of the model to be created. Multiple dispatch allows to definebuild_model
for every model type differently.df_train::DataFrame
: The training data frame. Used to get the size of the embedding layers based on the numbers of movies and users.df_test::DataFrame
: The testing data frame. Same asdf_train
.embeddings_size::Int=50 (optional)
: The size of the embedding vectors for both users and movies.share_embeddings::Any=nothing (optional)
: Redundant here. Used inGMFAndMLPModel
.
Returns
DotProductModel
: An instance of DotProductModel with the initialized Flux Chain.
Example
m = build_model(DotProductModel, df_train, df_test, embeddings_size=60)
build_model(x::Type{MLPSimilarityModel}, df_train::DataFrame, df_test::DataFrame; embeddings_size=50)
Constructs and returns an instance of MLPSimilarityModel using training and testing data sizes along with specified model parameters.
Arguments
x::Type{MLPSimilarityModel}
: The type of the model to be created. Multiple dispatch allows to definebuild_model
for every model type differently.df_train::DataFrame
: The training data frame. Used to get the size of the embedding layers based on the numbers of movies and users.df_test::DataFrame
: The testing data frame. Same asdf_train
.embeddings_size::Int=50 (optional)
: The size of the embedding vectors for both users and movies.share_embeddings::Any=nothing (optional)
: Redundant here. Used inGMFAndMLPModel
.
Returns
MLPSimilarityModel
: An instance of MLPSimilarityModel with the initialized Flux Chain.
Example
m = build_model(MLPSimilarityModel, df_train, df_test, embeddings_size=60)
build_model(x::Type{GMFAndMLPModel}, df_train::DataFrame, df_test::DataFrame; embeddings_size=50, share_embeddings=false)
Constructs and returns an instance of GMFAndMLPModel using training and testing data sizes along with specified model parameters.
Arguments
x::Type{GMFAndMLPModel}
: The type of the model to be created. Multiple dispatch allows to definebuild_model
for every model type differently.df_train::DataFrame
: The training data frame. Used to get the size of the embedding layers based on the numbers of movies and users.df_test::DataFrame
: The testing data frame. Same asdf_train
.embeddings_size::Int=50 (optional)
: The size of the embedding vectors for both users and movies.share_embeddings::Bool=false
: If settrue
, the embeddings will be shared between the GMF and MLP parts of the model. Otherwise, two separate sets of embeddings (4 Embedding layers in total).
Returns
GMFAndMLPModel
: An instance of GMFAndMLPModel with the initialized Flux Chain.
Example
m = build_model(model_type, df_train, df_test, embeddings_size=60, share_embeddings=true)