Frequently bought together/Complimentary in cart

Overview

The "Frequently Bought Together" feature enhances the shopping experience by suggesting complementary items based on the contents of a user's shopping cart. This feature uses item-based inference to identify and recommend products that are frequently purchased together.

Use Case

This approach is particularly effective for e-commerce platforms where cross-selling can significantly increase order value. It provides customers with suggestions that might be useful or necessary alongside their current selections.

Example Usage

To implement this feature, you need to pass the items currently in the user's cart to the recommendation engine. Set recommend_seen to False to ensure that the items already in the cart are not recommended again.

Preparing the Data

First, gather the IDs of the items in the user's cart. These IDs are used to fetch recommendations that complement the cart's contents.

items_in_cart = {
    "21253": {"timestamp": 1704060026, "rating": 1.0},
}

Making the API Call

Use the following API call to retrieve recommendations based on the items in the cart. Ensure your API endpoint is set up to handle item-based recommendations.

items_in_cart = {
    "21253": {"timestamp": 1704060026, "rating": 1.0},
}

recommendations = client.recommender.transformer.inference(
    user_interactions=items_in_cart,
    k=5,
    recommend_seen=False,
    model_name='demo-33fxfdfr'
)
print(recommendations)

Last updated