Home > Docs > Frequently Bought Together for WooCommerce > Working of Frequently Bought Together Algorithm

Working of Frequently Bought Together Algorithm

Last updated on July 27, 2023

The Frequently Bought Together (FBT) feature has become a popular addition to many e-commerce platforms. The plugin provides customers with personalized product recommendations based on the purchasing behavior of other users. In this article, we’ll dive into the technical aspects behind this feature to provide you with a deeper understanding of how it operates. The steps involved in the process are:

  1. Identifying the Reference Product.
  2. Establishing the Foreground Population.
  3. Identifying Frequently Co-occurring Products.
  4. Establishing Support Criteria.
  5. Evaluating Foreground Product Frequency.
  6. Determining the Background Population.
  7. Evaluating Background Product Frequency.
  8. Determining the Threshold Value.

Step 1: Identifying the Reference Product

The FBT feature starts by identifying the Reference product, which is the item that the user is presently seeing.

  • For example, consider a user is visiting a page with a mobile phone, then the reference product will be the mobile phone that’s currently on the page.

Step 2: Establishing the Foreground Population

To create a relevant set of product recommendations, the algorithm searches for customers who previously purchased the reference product, forming a group called the Foreground population. It analyzes the co-purchasing patterns within this group to identify products frequently bought alongside the reference product.

  • In our example, these would be the customers who have purchased mobile phones.
  • The Reference order count should be greater than the Minimum order count, which is set to 5 by default. To alter the value, refer to this article.

Step 3: Identifying Frequently Co-occurring Product

Next, the system looks for products that are frequently bought along with the reference product within the foreground population. These products are called Candidate products.

  • For example, if many customers who bought mobile phones also purchased headphones, then headphones become a candidate product for the FBT feature.

For reference Consider

  • Order count = 10000 (Total number of orders in the store).
  • Reference order count = 500 (number of smartphones purchased).
  • Order count of the candidate product = 100 (number of total headphones purchased).
  • Candidate order count = 50 (number of headphones bought together with the smartphone).

Step 4: Establishing Support Criteria

The FBT feature applies support criteria to ensure the relevance and significance of the co-occurrence. To achieve this, two support parameters are considered:

  1. Minimum Support Percentage (default_support_percentage): Minimum percentage of orders containing the reference product that must also include a candidate product. By default, the value is 5%. To alter the value, refer to this article.
    • That is, for 500 orders of smartphones, there should be at least 25 orders which contain a headphone too.
  2. Minimum Support Number of Orders (default_support_number): Minimum number of orders containing the reference product that must include a candidate product. By default, the value is set to 10. To alter the value, refer to this article.
    • That is, there should be a minimum of 10 orders where the smartphone and headphones are bought together.

Based on this data, a support number is calculated.

The support_number is calculated as the maximum value between the reference_order_count (the count of orders with the reference product) multiplied by the default_support_percentage and the default_support_number.

  • support_number = reference_order_count * default_support_percentage or the default_support_number
  • For the example considered, support_number = 500*5/100 or 10 = 25 or 10.
  • 25 is the maximum value, hence support_number = 25.

Step 5: Evaluating Foreground Product Frequency

The system evaluates the frequency of the foreground products, which are the candidate products identified in Step 3. The count of orders where these candidate products appear with the reference product is compared against the support_number.

If the foreground_order_count exceeds the support_number, the candidate product is considered to have significant co-occurrence with the reference product.

  • For the example considered, the foreground_order_count =50 and support_number = 25.
  • Hence, the headphone is considered a product that has significant co-occurrence with the reference product.

From these data, the foreground frequency is calculated.

The foreground_frequency is calculated as the foreground order count (orders containing the candidate product with the reference product) divided by the reference_order_count.

  • For the example considered, foreground_frequency = 50/500 = 0.1

Step 6: Determining the Background Population

To establish a benchmark and ensure context, the system expands its analysis to the entire population of orders, not just those containing the reference product. This is known as the Background population.

Step 7: Evaluating Background Product Frequency

The system determines the frequency of candidate products within the background population. It counts the number of orders containing each candidate product and compares it against the background_support_number, which is the minimum number of orders required for a candidate product to be considered significant. By default, the value is 10. To alter the value, refer to this article.

  • For example, there should be at least a minimum of 10 orders for the headphones in the entire population of orders.

From these data, the background frequency is calculated.

The background_frequency is calculated as the order count of the candidate product (from step 3) divided by the total number of orders (from step 3).

  • For the considered example, background frequency = 100/10000=0.01

Step 8: Determining the Threshold Value

The significance of a candidate product as an FBT recommendation is determined by calculating the significance_score.

This score is calculated by subtracting the background_frequency from the foreground_frequency and multiplying it by the ratio of foreground_frequency to background_frequency.

If the significance_score exceeds a predefined min_threshold which is 0.2, the candidate product is considered an FBT product. To alter the value, refer to this article.

  • significance_score = (foreground_frequency – background_frequency) * (foreground_frequency / background_frequency)
  • For the considered example, significance_score = (0.1 – 0.01)*(.1/0.01) = 0.9.
  • significance_score (0.9) > min_threshold (0.2)
  • Hence, headphone is considered a frequently bought together product.

Available Variables

  1. default_support_percentage – Minimum percentage of orders containing the reference product that must also include a candidate product.
  2. default_support_number – Minimum number of orders containing the reference product that must include a candidate product.
  3. reference_order_count – the count of orders with the reference product
  4. support_number – Maximum value between the reference_order_count multiplied by the default_support_percentage and the default_support_number.
  5. foreground_frequencyforeground_order_count divided by the reference_order_count
  6. background_support_number – Minimum number of orders required for a candidate product to be considered significant.
  7. significance_score – Subtracting the background_frequency from the foreground_frequency and multiplying it by the ratio of foreground_frequency to background_frequency.