algo-rec-mf

Solid

"Implement matrix factorization to decompose user-item interaction matrices into latent factor representations. Use this skill when the user needs scalable collaborative filtering, latent feature discovery, or dimensionality reduction for recommendation — even if they say 'SVD recommendations', 'latent factors', or 'factorize the rating matrix'.".

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

# Matrix Factorization ## Overview Matrix factorization decomposes the user-item interaction matrix R (m×n) into two low-rank matrices: U (m×k) and V (n×k), where k << min(m,n). Predicted rating: r̂ᵢⱼ = uᵢ · vⱼ. Trains in O(k × nnz × iterations) where nnz = non-zero entries. ## When to Use **Trigger conditions:** - Scaling CF beyond pairwise similarity (millions of users/items) - Discovering latent factors that explain user-item interactions - Predicting ratings for unobserved user-item pairs **When NOT to use:** - When interaction data is extremely sparse (< 0.1% fill) — insufficient for learning - When you need real-time updates (retraining is expensive) ## Algorithm ``` IRON LAW: Rank k Controls Bias-Variance Trade-Off - Too LOW k: underfits, misses nuanced preferences (high bias) - Too HIGH k: overfits to noise, poor generalization (high variance) - Typical k: 20-200. Select via cross-validation on held-out ratings. - Always add regularization (λ) to prevent overfitting. ``` ### Phase 1: Input Validation Load sparse interaction matrix. Split into train/validation/test. Check minimum density. **Gate:** Train matrix has sufficient entries per user and item. ### Phase 2: Core Algorithm **ALS (Alternating Least Squares):** 1. Initialize U, V randomly (or with SVD warm-start) 2. Fix V, solve for U: minimize ||R - UV^T||² + λ(||U||² + ||V||²) 3. Fix U, solve for V using same objective 4. Alternate until convergence (RMSE change < ε) **SGD alternative:** Update u_i, v_...

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

AI & Automation Solid

algo-rec-cf

"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'.".

22 Updated 6 days ago
charlieviettq
AI & Automation Solid

algo-rec-content

"Implement content-based recommendation by matching item features to user preference profiles. Use this skill when the user needs to recommend items based on attributes, solve the cold start problem for new items, or build recommendations without collaborative data — even if they say 'recommend similar products', 'items like this', or 'feature-based matching'.".

22 Updated 6 days ago
charlieviettq
AI & Automation Listed

factor-research

Evaluate whether a cross-sectional factor genuinely predicts returns. Trigger for "这个因子有效吗", "算一下IC", "动量因子在A股还有效吗", "帮我评估这个选股信号", "factor IC", "is this signal predictive", "compare momentum vs value factors", or whenever the user (1) proposes or computes a ranking/score across assets and asks if it works, (2) asks which factor explains recent moves, (3) wants factors screened/ranked before building a strategy, or (4) hands a signal to strategy construction. Fire even for informal phrasing ("这个指标选股靠谱吗"). Do NOT trigger for single-asset technical indicator questions (no cross-section) or for validating a finished strategy's returns (that is backtest-validation).

2 Updated 1 weeks ago
artherahq