algo-rec-sessionlisted
Install: claude install-skill charlieviettq/awesome-agent-skill
# Session-Based Recommendation
## Overview
Session-based recommendation predicts the next item a user will interact with based on their current session's click/view sequence, without relying on long-term user profiles. Uses Markov chains, association rules, or neural approaches (GRU4Rec). Operates in real-time with O(sequence_length) inference.
## When to Use
**Trigger conditions:**
- Anonymous users (no login, no long-term profile)
- Short browsing sessions where recency matters most
- Real-time "next item" prediction during active sessions
**When NOT to use:**
- When rich user history is available (use CF or content-based for better personalization)
- When sessions are extremely short (1-2 clicks) — insufficient signal
## Algorithm
```
IRON LAW: First Few Clicks Are Disproportionately Important
Session-based methods operate WITHOUT long-term profiles. Intent must
be inferred from SHORT sequences. The first 2-3 clicks establish the
session's intent — misreading early signals derails the entire session.
```
### Phase 1: Input Validation
Parse clickstream into sessions (by session ID or timeout-based splitting, typically 30min inactivity). Filter sessions below minimum length (3+ events).
**Gate:** Sessions parsed, minimum length threshold applied.
### Phase 2: Core Algorithm
**Markov Chain approach:**
1. Build transition matrix from item-to-item sequences across all sessions
2. For current session [A, B, C], predict next item from P(next | C) or higher-order P(next |