algo-rec-cf

Solid

"Implement collaborative filtering for recommendations based on user behavior patterns. Use this skill when the user needs to build a recommendation engine from user-item interaction data, find similar users or items, or predict ratings — even if they say 'users who bought this also bought', 'similar users', or 'recommend based on behavior'.".

AI & Automation 22 stars 8 forks Updated 6 days ago MIT

Install

View on GitHub

Quality Score: 84/100

Stars 20%
45
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
80
License 10%
100
Description 5%
100

Skill Content

# Collaborative Filtering ## Overview Collaborative filtering recommends items based on collective user behavior patterns. User-based CF finds similar users; item-based CF finds similar items. Computes in O(U² × I) for user-based or O(I² × U) for item-based where U=users, I=items. ## When to Use **Trigger conditions:** - Building recommendations from user-item interaction data (ratings, clicks, purchases) - Finding "users like you also liked" or "frequently bought together" patterns **When NOT to use:** - When you have no interaction data (cold start — use content-based filtering) - When item features matter more than behavior patterns (use content-based) ## Algorithm ``` IRON LAW: CF Requires SUFFICIENT Interaction Data With sparse matrices (< 1% fill rate), similarity computation is unreliable. Minimum viable: each user has rated 5+ items, each item has 5+ ratings. Below this, fallback to content-based or popularity. ``` ### Phase 1: Input Validation Load user-item interaction matrix. Check sparsity level and filter users/items below minimum interaction threshold. **Gate:** Matrix sparsity < 99%, minimum interaction thresholds met. ### Phase 2: Core Algorithm **User-based CF:** 1. Compute pairwise user similarity (cosine or Pearson correlation) 2. For target user, find top-K most similar users 3. Predict rating: weighted average of similar users' ratings **Item-based CF:** 1. Compute pairwise item similarity from co-rating patterns 2. For target item, find top-K m...

Details

Author
charlieviettq
Repository
charlieviettq/awesome-agent-skill
Created
2 months ago
Last Updated
6 days ago
Language
Python
License
MIT

Similar Skills

Semantically similar based on skill content — not just same category