agentleFS
afelipegafelipeg/Anthropic-Skills-for-enterprise-marketing-os/skills/recommender-systems/SKILL.md

recommender-systems

Skill1 starsChanged 7 months agoMITView on GitHub

Builds personalized product recommendation engines using content-based filtering, collaborative filtering (user/item neighborhood), latent factor models (SVD, SVD++, NMF), hybrid blending/stacking, contextual pre-filtering, and non-personalized association rules. Use when asked to: build a recommendation engine, personalize product suggestions, solve cold-start problem, rank products by affinity, improve upsell/cross-sell, compute similarity between items or users, evaluate recommender quality (RMSE, NDCG@K, precision@K), or combine multiple models. Also trigger when someone says "recommendation engine", "collaborative filtering", "content-based filtering", "SVD", "latent factors", "cold-start problem", "similar products", "frequently bought together", "next best product", "blending models", "NDCG", "precision@K", or pastes a user-item rating matrix. Always renders inline HTML dashboard + marketer NBA and industry benchmarks.

The file

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 5 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈5

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Plain language: not just what you rated, but which items you interacted with at all.

    line 96
  2. Distinctive:

    Always search before responding:

    line 214
  3. Distinctive:

    Always produce 4–6 specific, actionable recommendations:

    line 232
  4. Distinctive:

    Always link output to one of: acquisition, maximization, retention (Katsov §3.2):

    line 244
  5. Distinctive:

    Platform RMSE is not business ROI: Always tie precision@K to revenue per recommendation slot via A/B test.

    line 258

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Recommender Systems

Personalized recommendation engine builder. Six algorithm families + hybrid blending + evaluation suite. Always outputs three layers: technical model → evaluation metrics → marketer-ready insights + NBA.


How Recommendations Work — Plain Language

A recommender system answers one question: "What should this specific customer see next?"

Three approaches, in order of sophistication:

CONTENT-BASED:  "You liked X → show things similar to X"
                Uses: item descriptions, categories, attributes
                Good for: new items, cold-start users

COLLABORATIVE:  "People like you bought Y → you'll probably like Y too"
                Uses: the full rating/purchase matrix
                Good for: established users, serendipitous discovery

LATENT FACTORS: "You secretly love 'indie thriller sci-fi' even if you never said so"
                Uses: hidden patterns learned from all interactions simultaneously
                Good for: scale, accuracy, the Netflix Prize winner was this

Hybrid combines all three. Contextual adds time, location, device. Association rules ("people who buy diapers also buy beer") work without any profile.


Algorithm Selection

ScenarioMethodScript
New items or users (cold-start)Content-Based KNNcontent_based_knn.py
Established users, small catalogUser-Based CFuser_based_cf.py
Large catalog, scalableItem-Based CFitem_based_cf.py
Best accuracy, Netflix-styleSVD / SVD++svd_basic.py / svdpp.py
Non-negative (interpretable)NMFnmf.py
Maximum accuracy (production)Hybrid Blendinghybrid_blending.py
Day/time/location contextContextual Pre-Filtercontextual_prefilter.py
No profile neededAssociation Rulesnon_personalized_association.py
Evaluate any modelTop-K Evaluatorevaluate_top_k.py

→ Read references/algorithm_selection.md for detailed decision tree.


Core Equations (Katsov Ch. 5)

Latent Factor Model (eq. 5.92–5.96)

# Rating prediction from latent factors:
r̂_ui = p_u · q_i^T = Σ_{s=1}^{k}  p_us * q_is

# SVD decomposition (eq. 5.95–5.96):
R = UΣV^T  →  R̂ = U_k Σ_k V_k^T

# Full model with biases:
r̂_ui = μ + b_i + b_u + p_u · q_i^T

# Gradient descent updates:
b_u ← b_u + α(e - λ·b_u)
b_i ← b_i + α(e - λ·b_i)
p_u ← p_u + α(e·q_i - λ·p_u)
q_i ← q_i + α(e·p_u - λ·q_i)

SVD++ with Implicit Feedback (eq. 5.117–5.119)

r̂_ui = μ + b_i + b_u + (p_u + |I_u|^{-1/2} Σ_{j∈I_u} y_j) · q_i^T

Plain language: not just what you rated, but which items you interacted with at all.

Blending / Stacking (eq. 5.122–5.125)

# Linear blend of q model outputs (eq. 5.124):
r̂_ui = Σ_{k=1}^{q}  w_k · r̂_ui^{(k)}

# Ridge regression for weights (eq. 5.125):
w = (X^T X + λI)^{-1} X^T y

Quality Metrics (eq. 5.5–5.11)

RMSE = √(1/|T| Σ e_uj²)                          [eq. 5.6]
precision@K = |Y_u(K) ∩ I_u| / K                 [eq. 5.8]
recall@K    = |Y_u(K) ∩ I_u| / |I_u|             [eq. 5.9]
DCG@K       = Σ_{i=1}^{K} (2^{r_ui}-1)/log₂(i+1) [eq. 5.10–5.11]

Workflow

Step 1 — Load & Inspect Data

python scripts/evaluate_top_k.py --inspect --data data/ratings.csv

Output: sparsity %, user/item count, rating distribution, cold-start profile.

Step 2 — Choose & Train Model

# Content-based (cold-start safe):
python scripts/content_based_knn.py --items data/items.csv --k 20

# Collaborative filtering:
python scripts/item_based_cf.py --ratings data/ratings.csv --k 30

# Latent factors (best accuracy):
python scripts/svd_basic.py --ratings data/ratings.csv --factors 50 --epochs 20

# SVD++ (adds implicit feedback):
python scripts/svdpp.py --ratings data/ratings.csv --factors 50 --epochs 20

Step 3 — Evaluate

python scripts/evaluate_top_k.py \
    --predictions results/predictions.csv \
    --test data/test_ratings.csv \
    --k 10 \
    --output results/eval_metrics.json

Step 4 — Hybrid Blend (optional, +5–15% improvement)

python scripts/hybrid_blending.py \
    --model-outputs results/svd_pred.csv,results/item_cf_pred.csv \
    --test data/test_ratings.csv \
    --output results/blend_weights.json

Step 5 — Export Dashboard + Insights

python scripts/export_rec_dashboard_json.py \
    --eval results/eval_metrics.json \
    --model-type svd \
    --output dashboard_data.json

Output sequence:

1. [bash_tool] Train + evaluate model
2. [web_search] Industry benchmarks for sector/category (precision@K, CTR lift, revenue uplift)
3. [bash_tool] export_rec_dashboard_json.py → JSON
4. [show_widget] HTML dashboard: metrics + model comparison + HR leaderboard
5. [text] CMO/marketer insights: what this means + NBA (Next Best Actions)
6. [text] Caveats: cold-start, popularity bias, filter bubble risk

Scripts Reference

ScriptKey InputsKey Output
content_based_knn.pyitems.csv (features), ratings.csvPer-user top-K recs + similarity matrix
user_based_cf.pyratings matrixPer-user recs via Pearson/cosine similarity
item_based_cf.pyratings matrixPer-user recs via item-item similarity
svd_basic.pyratings matrix, k, epochsP/Q factor matrices + predictions
svdpp.pyratings matrix, k, epochsSVD++ predictions (implicit feedback)
nmf.pyratings matrix, kNon-negative factor matrices
hybrid_blending.pymultiple prediction CSVsBlend weights + blended predictions
contextual_prefilter.pyratings + context CSVContext-sliced rating matrix
non_personalized_association.pytransactions CSVAssociation rules (support, confidence, lift)
evaluate_top_k.pypredictions + test ratingsRMSE, precision@K, recall@K, NDCG@K, coverage
export_rec_dashboard_json.pyeval JSONDashboard-ready JSON

Output Format — Visualization First

Primary output: inline HTML dashboard. Always render before any text.

Dashboard panels (see references/rec_dashboard_template.html):

  1. KPI bar — RMSE, precision@10, NDCG@10, catalog coverage, model type
  2. Algorithm leaderboard — bar chart comparing models if multiple evaluated
  3. Precision-Recall curve — varying K from 1→50
  4. Rating distribution — original vs predicted
  5. Association rules table — top rules by lift (for non-personalized)
  6. Business impact estimate — revenue uplift estimate from benchmark

Marketer Insights Layer (MANDATORY for every activation)

This section must always be produced after the technical output.

1. Web Search for Industry Benchmarks

Always search before responding:

web_search: "recommendation engine CTR uplift [industry] benchmark [year]"
web_search: "precision@10 recommender system [ecommerce/streaming/retail] industry average"

2. Translate Metrics to Business Language

Technical metricBusiness meaningTypical industry range
precision@10"1 in X recommended products gets clicked/bought"5–30% (ecommerce)
RMSE < 0.9"Rating predictions are within ~1 star of truth"Netflix benchmark: 0.85
NDCG@10 > 0.6"The right products appear near the top of the list"Good = 0.6–0.8
coverage > 30%"30%+ of catalog gets recommended to someone"Prevents long-tail waste
HR (hit rate)"% of sessions where at least 1 rec was relevant"Amazon: ~35%

3. NBA — Next Best Actions for Marketers/CMOs

Always produce 4–6 specific, actionable recommendations:

Template (adapt to context):

  • Placement: "Deploy these recommendations in [cart page / email / home page] for highest conversion lift"
  • Cold-start: "For new users, use content-based recs until they accumulate 5+ interactions, then switch to collaborative filtering (switching hybrid, eq. 5.121)"
  • Segmentation: "Run separate models per [segment / category] — model accuracy is higher for homogeneous populations"
  • Testing: "A/B test: control=current merchandising rules, treatment=this model. Measure GMV uplift over 4 weeks minimum"
  • Refresh: "Retrain model weekly if CTR drops >15% from baseline — signals user drift"
  • Diversity: "Cap any single brand/category at 30% of recommendation list to avoid filter bubble and improve catalog coverage"

4. Connect to Business Objectives

Always link output to one of: acquisition, maximization, retention (Katsov §3.2):

  • Acquisition: content-based recs on landing pages → introduce new users to catalog
  • Maximization: item-based CF on PDP (Product Detail Page) → cross-sell / upsell
  • Retention: personalized email recommendations → reduce churn, increase frequency

Key Caveats

  • Popularity bias: Most CF models over-recommend popular items. Counteract with diversity re-ranking.
  • Filter bubble: Pure collaborative filtering creates echo chambers. Mix with serendipity score (§5.3.4).
  • Cold-start: New items/users have no interaction history → fall back to content-based (eq. 5.121 switching).
  • Implicit feedback: Purchases ≠ preferences. A customer may have returned the item. SVD++ handles this better (eq. 5.117).
  • Sparsity threshold: CF degrades when <1% of ratings are known. Use NMF or content-based below 0.5% sparsity.
  • Platform RMSE is not business ROI. Always tie precision@K to revenue per recommendation slot via A/B test.

Integration with Agency Growth OS

SkillHandoff
audience-segmentation-briefPersona segments → separate rec models per persona
response-uplift-modelingRecommendation click → treatment for uplift model
crm-journey-architectTop-K recs → product slots in CRM email templates
measurement-incrementalityA/B test on rec engine → revenue uplift proof
creative-supply-plannerTop recommended items → prioritize creative production

Reference Files

  • references/algorithm_selection.md — Full decision tree: sparsity × cold-start × scale
  • references/katsov_rec_excerpts.md — Key equations §5.3–5.12 + Netflix Prize context
  • references/industry_benchmarks.md — Sector benchmarks (search before using; may be stale)
  • references/rec_dashboard_template.html — HTML dashboard; inject SKILL_DATA_JSON

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.