Prerequisites
Before proceeding, ensure the following prerequisites are met:- Install MindsDB locally via Docker or Docker Desktop.
- To use LightFM within MindsDB, install the required dependencies following this instruction.
Please note that, if you are using Docker to run MindsDB, before installing the dependencies for this integration as per the instructions given above, it is currently necessary to install a couple of Linux development packages in the container. To do this, run the following commands:Start an interactive shell in the container:If you haven’t specified a name when spinning up the MindsDB container with
docker run, you can find it by running docker ps.Install the required Linux development packages:Please note that at the moment this integration does not support the
FINETUNE feature.Example
Before creating a LightFM model, we need to create an ML engine.SHOW ML_ENGINES.
Now let’s create a LightFM model specifying the necessary input parameters.
- The
item_idparameter that stores items to be recommended; here, these are movies. - The
user_idparameter that stores users to whom items are recommended. - The
thresholdparameter is used when score of interaction is provided in the input data. It defines the threshold for the recommendation. - The
n_recommendationsparameter stores the number of recommendations to be returned.
evaluation parameter if you want to store the evaluation metrics. It is set to false by default.
Here is how to connect the
mysql_demo_db used for training the model:-
Get recommendations for all item_item pairs:
-
Get item-item recommendations for a specific item_id:
-
Get recommendations for all user-item pairs:
-
Get user-item recommendations for a specific user_id:
-
Get user-item recommendations for multiple user_ids: