# Presets (default algorithms)

## What you will find here ?&#x20;

{% columns %}
{% column width="75%" %}
How dynamic contextual rules and algorithms work within **AB Tasty’s Recommendations & Merchandising platform**. It covers the six main “starting points” available when building a strategy, along with a full reference of available algorithms.

Dynamic contextual rules use **real-time contextual variables** (page type, category, viewed/bought items, recency, frequency, etc.) to return relevant, up-to-date product sets for each user or page.
{% endcolumn %}

{% column width="25%" %}

<figure><img src="https://2350286830-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6Yw9IRJ6KbbucQPwZUCZ%2Fuploads%2FX4LUPbIlxk4s0Hzl66hx%2Fimage.png?alt=media&#x26;token=faf28dd9-e0fa-4322-9391-16302d63c222" alt=""><figcaption></figcaption></figure>
{% endcolumn %}
{% endcolumns %}

### **Items sorted by**

**Definition**\
Returns products based on a chosen property or performance metric (e.g., sales, recency, margin, page views, purchased quantities).\
These are typically “Top X Products” strategies ordered by KPI and timeframe.

**Logic**\
The rule aggregates catalog and event data (page views, purchases, revenue, quantities) over a defined period, ranks the products, and returns the highest-scoring ones.

| Parameter          | Description                                          | Example                                                         |
| ------------------ | ---------------------------------------------------- | --------------------------------------------------------------- |
| **Input variable** | Global or category scope (`categoryId`, `page_type`) | `categoryId = “Shoes”`                                          |
| **Algorithm**      | Aggregates metrics over X days                       | `pageviews_last_7_days`, `revenues_last_30_days`, `trend`, etc. |
| **Output**         | Ranked list of best-performing products              | Top 50 bestsellers last 30 days                                 |
| **Dynamic**        | Auto-updates as data evolves (daily/hourly refresh)  | —                                                               |

**Use cases**

* *Top sellers* of the last 30 days
* *Newest arrivals* (sorted by creation date)
* *Trending products* (based on sales velocity ratio)
* *Most relevant products* (weighted by conversion × recency × stock)

***

### **Items associated to**

**Definition**\
Returns products most often purchased or viewed together with the current product (“complementary logic”).\
Built on **co-occurrence** and **TF-IDF weighting** to detect statistically meaningful associations.

**Logic**

| Parameter          | Description                                                   | Example                              |
| ------------------ | ------------------------------------------------------------- | ------------------------------------ |
| **Input variable** | Current product ID (`productId`) or basket IDs (`cart_items`) | `"SKU12345"`                         |
| **Algorithm**      | TF-IDF based co-occurrence analysis                           | “Bought together”, “Viewed together” |
| **Output**         | Complementary product set                                     | Printer → Ink cartridges             |
| **Dynamic**        | Real-time refresh with new behavioral data                    | —                                    |

**Use cases**

* *Frequently bought together*
* *Cross-sell bundles* (e.g., accessories, consumables)
* *Cart-based add-ons* (threshold fillers or impulse buys)

***

### **Items similar to**

**Definition**\
Returns products that share strong affinities with the current one — acting as alternatives within the same universe.\
Built using **co-occurrence + TF-IDF weighting**, **attribute-based matching**, or **embedding similarity** (semantic / visual).

**Logic**

| Parameter          | Description                                            | Example                                  |
| ------------------ | ------------------------------------------------------ | ---------------------------------------- |
| **Input variable** | Current product attributes (`productId`, `categoryId`) | `"SKU7890"`                              |
| **Algorithm**      | Similarity scoring model                               | “Similar products”, “Semantic”, “Visual” |
| **Output**         | List of substitute or style-related products           | “Another Oxford shirt in blue”           |
| **Dynamic**        | Updates as catalog and user signals change             | —                                        |

**Use cases**

* *Alternative products* on PDP (prevent exit)
* *Style discovery* (same color / material / collection)
* *Niche promotion* (long-tail visibility for new SKUs)

***

### **Items from recommendation**

**Definition**\
Reuses the **output of an existing recommendation rule**.\
Used to compose multi-layered or conditional strategies.

**Logic**

| Parameter          | Description                                     | Example                                     |
| ------------------ | ----------------------------------------------- | ------------------------------------------- |
| **Input variable** | Output of a previous strategy                   | “Top sellers in category”                   |
| **Algorithm**      | Sequential chaining / composition               | Apply filter `stock > 0` on previous output |
| **Output**         | Filtered or refined set of recommended products | Top sellers with stock > 0 & margin > 20%   |

**Use cases**

* *Composed strategies*: combine multiple rules in sequence
* *Fallbacks*: use another recommendation if the first returns too few products

***

### **Manual selection**

**Definition**\
A **fixed curated list** of products chosen by a merchandiser.\
Ideal for campaign or editorial content that should not change dynamically.

| Parameter          | Description                      | Example                          |
| ------------------ | -------------------------------- | -------------------------------- |
| **Input variable** | Product IDs manually selected    | `[“SKU111”, “SKU222”, “SKU333”]` |
| **Algorithm**      | None (static list)               | —                                |
| **Output**         | Always the same set until edited | “Christmas collection”           |
| **Dynamic**        | Manual only                      | —                                |

**Use cases**

* *Seasonal campaigns* (e.g., Christmas, Black Friday)
* *Editorial picks* (lookbooks / content curation)
* *Hero products* for brand priorities or high margin

***

### **Products from variable**

**Definition**\
Returns products based on a **dynamic contextual variable** from the page or user session.\
Typical examples: current category, basket content, recently viewed items, or user profile segments.

| Parameter          | Description                                        | Example                                                    |
| ------------------ | -------------------------------------------------- | ---------------------------------------------------------- |
| **Input variable** | Dynamic contextual variable                        | `categoryId`, `user_recent_basket`, `last_viewed_products` |
| **Algorithm**      | Variable-driven lookup rule                        | “Best sellers in current category”                         |
| **Output**         | Contextual set of products linked to that variable | Personalized continuity                                    |
| **Dynamic**        | Automatically adjusts to user context              | —                                                          |

**Use cases**

* *Category best sellers* (using `categoryId`)
* *Recently viewed products* (using `last_viewed_products`)
* *Basket-based rules* (using `user_recent_basket`)
* *“Because you viewed…”* personalization

***

### **Let’s deep dive into the three core algorithms powering AB Tasty Recommendations & Merchandising**

Each of them plays a unique role in how products are ranked and displayed - from behavioral patterns to semantic understanding.

| Algorithm         | Signal Type           | Data Source                        | Main Objective                                 | Typical Use Cases                              | Link to specific documentation                                                                                                                                                                                                                                    |
| ----------------- | --------------------- | ---------------------------------- | ---------------------------------------------- | ---------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Co-occurrence** | Behavioral            | Orders, sessions, views            | Identify products often bought/viewed together | “Frequently bought together”                   | [Co-occurence documentation link](https://app.gitbook.com/o/iFKI1JaxSfPoiGt4tT2k/s/6Yw9IRJ6KbbucQPwZUCZ/~/changes/358/recommendations-and-merchandising-1/concepts/strategies/rules/ranking-blocks-default-algorithms/co-occurrence)                              |
| **TF-IDF**        | Statistical weighting | Co-occurrence + global frequency   | Reduce bias from generic products              | “Next book in a series” instead of “Gift card” | [TF-IFD documentation link](https://app.gitbook.com/o/iFKI1JaxSfPoiGt4tT2k/s/6Yw9IRJ6KbbucQPwZUCZ/~/changes/358/recommendations-and-merchandising-1/concepts/strategies/rules/ranking-blocks-default-algorithms/tf-idf-term-frequency-inverse-document-frequency) |
| **Semantic**      | Contextual (NLP)      | Product text, attributes, metadata | Find products similar in meaning or style      | “Other running shoes”                          | [Semantic Cosine Distance documentation link](https://app.gitbook.com/o/iFKI1JaxSfPoiGt4tT2k/s/6Yw9IRJ6KbbucQPwZUCZ/~/changes/358/recommendations-and-merchandising-1/concepts/strategies/rules/ranking-blocks-default-algorithms/semantic-similarity)            |

### How dynamic rules and algorithms work within **AB Tasty’s Recommendations & Merchandising platform?**

It covers the six main “starting points” available when building a strategy, along with a full reference of available algorithms.

Dynamic contextual rules use **real-time contextual variables** (page type, category, viewed/bought items, recency, frequency, etc.) to return relevant, up-to-date product sets for each user or page.

***

### 🧩 Appendix — All Available Algorithms

| Algorithm Name                      | Translation                 | Definition                                                                     |
| ----------------------------------- | --------------------------- | ------------------------------------------------------------------------------ |
| `pageviews_last_7_days`             | 7-day page views            | Products with the most views over the last 7 days.                             |
| `pageviews_last_14_days`            | 14-day page views           | Products with the most views over the last 14 days.                            |
| `pageviews_last_30_days`            | 30-day page views           | Products with the most views over the last 30 days.                            |
| `trend`                             | Trend ratio                 | Ratio of page views between the last and previous period (velocity indicator). |
| `revenues_last_30_days`             | 30-day revenue              | Products generating the highest revenue over the last 30 days.                 |
| `revenues_last_14_days`             | 14-day revenue              | Products generating the highest revenue over the last 14 days.                 |
| `revenues_last_7_days`              | 7-day revenue               | Products generating the highest revenue over the last 7 days.                  |
| `quantities_purchased_last_7_days`  | 7-day purchased quantities  | Products with the highest number of units sold in the last 7 days.             |
| `quantities_purchased_last_14_days` | 14-day purchased quantities | Products with the highest number of units sold in the last 14 days.            |
| `quantities_purchased_last_30_days` | 30-day purchased quantities | Products with the highest number of units sold in the last 30 days.            |

*(If your CSV contains additional specialized variants, e.g., “margin\_last\_30\_days”, they can be added under the same pattern.)*

***

### 🔄 **Data Flow & Dynamic Variable Usage**

Dynamic contextual variables (see dedicated glossary) drive these recommendation rules:

* **`page_type`** determines which rule is triggered (homepage vs PDP vs cart).
* **`viewed_items`**, **`bought_items`**, **`cart_items`** feed “associated” and “similar” rules.
* **`recency`**, **`frequency`**, and **`monetary`** score freshness and priority.
* **`categoryId`**, **`productId`**, and **`user_recent_basket`** define the contextual scope for “products from variable”.

Flow overview:\
`User Event (Tag)` → `Contextual Variables updated` → `Rule Evaluation (Algo)` → `Filtered Product List` → `Display on Site / Feed Analytics`.
