Documentation Home
MySQL AI 9.5
Related Documentation Download this Manual
PDF (US Ltr) - 1.5Mb
PDF (A4) - 1.5Mb


MySQL AI 9.5  /  ...  /  Generating Predictions for a Recommendation Model

4.6.5.4 Generating Predictions for a Recommendation Model

After training the model, you can generate predictions. To generate predictions, use the sample data from the testing_dataset dataset. NULL values for any row in the users or items columns generates an error.

Before You Begin

Complete the following tasks:

Options for Generating Predictions

The options for ML_PREDICT_ROW and ML_PREDICT_TABLE include the following:

  • threshold: The optional threshold that defines positive feedback, and a relevant sample. Only use with ranking metrics. It can be used for either explicit or implicit feedback.

  • topk: The number of recommendations to provide. The default is 3.

  • recommend: Specifies what to recommend. Permitted values are:

    • ratings: Predicts ratings that users will give. This is the default value.

    • items: Recommends items for users.

    • users: Recommends users for items.

    • users_to_items: This is the same as items.

    • items_to_users: This is the same as users.

    • items_to_items: Recommends similar items for items.

    • users_to_users: Recommends similar users for users.

  • remove_seen: If true, the model does not repeat existing interactions from the training table. It only applies to the recommendations items, users, users_to_items, and items_to_users.

  • item_metadata: Defines the table that has item descriptions. It is a JSON object that has the table_name option as a key, which specifies the table that has item descriptions. One column must be the same as the item_id in the input table.

  • user_metadata: Defines the table that has user descriptions. It is a JSON object that has the table_name option as a key, which specifies the table that has user descriptions. One column must be the same as the user_id in the input table.

    • table_name: To be used with the item_metadata and user_metadata options. It specifies the table name that has item or user descriptions. It must be a string in a fully qualified format (schema_name.table_name) that specifies the table name.

Generating Predictions with the TwoTower Recommendation Model

If the model is trained with the TwoTower recommendation model, keep in mind the following:

  • You have the option to specify additional user and item desciptions by using the item_metadata and user_metadata options.

  • If there are missing descriptions for users and items, these missing descriptions are inferred when generating predictions.

  • If user and items descriptions are provided for training, they are ignored when generating predictions. Instead, the generated embeddings for the users and items are used to generate predictions.

  • The ML_PREDICT_ROW routine is not supported.