Recommendation Engine
БесплатноЗапускает вложенные скриптыНе проверенBuild recommendation systems using collaborative filtering, content-based filtering, matrix factorization, and neural network approaches
Об этом скилле
Recommendation Engine
Overview
This skill provides comprehensive implementation of recommendation systems using collaborative filtering, content-based filtering, matrix factorization, and hybrid approaches to predict user preferences and deliver personalized suggestions.
When to Use
- Building personalized product recommendations for e-commerce platforms
- Creating content recommendation systems for streaming services, news platforms, or social media
- Implementing user-user or item-item collaborative filtering based on interaction patterns
- Addressing cold start problems for new users or items with limited interaction history
- Evaluating recommendation quality using precision@k, recall@k, and NDCG metrics
- Scaling recommendation systems to handle millions of users and items efficiently
Recommendation Approaches
- Collaborative Filtering: Using user-item interaction patterns
- Content-Based: Recommending similar items based on features
- Hybrid: Combining multiple approaches
- Matrix Factorization: Decomposing user-item matrix
- Neural Networks: Deep learning for embeddings
- Knowledge-Based: Using domain knowledge and rules
Key Techniques
- User-User Similarity: Finding similar users
- Item-Item Similarity: Finding similar items
- Latent Factors: Hidden patterns in data
- Embeddings: Vector representations of users/items
- Graph-Based: Social networks and item graphs
Python Implementation
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.metrics.pairwise import cosine_similarity, euclidean_distances
from sklearn.decomposition import TruncatedSVD
from sklearn.feature_extraction.text import TfidfVectorizer
from scipy.sparse import csr_matrix
import warnings
warnings.filterwarnings('ignore')
print("=== 1. Collaborative Filtering ===")
# Create sample user-item interaction matrix
np.random.seed(42)
n_users = 50
n_items = 30
# Create sparse interaction matrix (ratings: 0-5)
interaction_matrix = np.random.randint(0, 6, size=(n_users, n_items))
# Make it sparse (many zeros)
interaction_matrix[np.random.random((n_users, n_items)) > 0.3] = 0
print(f"User-Item Matrix Shape: {interaction_matrix.shape}")
print(f"Sparsity: {(interaction_matrix == 0).sum() / interaction_matrix.size:.2%}")
# User-based collaborative filtering
print("\n=== User-Based Collaborative Filtering ===")
# Normalize ratings
user_means = np.nanmean(np.where(interaction_matrix != 0, interaction_matrix, np.nan), axis=1, keepdims=True)
user_means[np.isnan(user_means)] = 0
interaction_normalized = interaction_matrix - user_means
# Convert to sparse matrix
interaction_sparse = csr_matrix(interaction_normalized)
# Compute user-user similarity
user_similarity = cosine_similarity(interaction_sparse)
print(f"User Similarity Matrix Shape: {user_similarity.shape}")
print(f"Sample user similarity [0,1]: {user_similarity[0, 1]:.4f}")
# 2. Item-based collaborative filtering
print("\n=== Item-Based Collaborative Filtering ===")
# Compute item-item similarity
item_similarity = cosine_similarity(interaction_sparse.T)
print(f"Item Similarity Matrix Shape: {item_similarity.shape}")
print(f"Sample item similarity [0,1]: {item_similarity[0, 1]:.4f}")
# 3. Matrix Factorization (SVD)
print("\n=== Matrix Factorization (SVD) ===")
# Apply SVD
svd = TruncatedSVD(n_components=5, random_state=42)
user_factors = svd.fit_transform(interaction_sparse)
item_factors = svd.components_.T
print(f"User Factors Shape: {user_factors.shape}")
print(f"Item Factors Shape: {item_factors.shape}")
print(f"Explained Variance Ratio: {svd.explained_variance_ratio_.sum():.4f}")
# Reconstruct ratings
reconstructed_ratings = user_factors @ item_factors.T + user_means
print(f"Reconstructed Ratings Shape: {reconstructed_ratings.shape}")
print(f"Reconstruction Error: {np.mean((interaction_matrix - reconstructed_ratings) ** 2):.4f}")
# 4. Content-Based Filtering
print("\n=== Content-Based Filtering ===")
# Create item features (e.g., product descriptions)
item_descriptions = [
"action adventure movie thriller",
"romantic comedy drama love",
"sci-fi technology future space",
"horror scary thriller dark",
"animation family kids fun",
"adventure action explosions",
"documentary educational learning",
"sports competition championship",
"musical dance entertainment",
"historical drama biography"
]
# Expand to 30 items
item_descriptions = (item_descriptions * 4)[:30]
# Create TF-IDF vectors
tfidf = TfidfVectorizer(lowercase=True)
item_features = tfidf.fit_transform(item_descriptions)
# Compute item-item similarity based on content
content_similarity = cosine_similarity(item_features)
print(f"Item Feature Matrix Shape: {item_features.shape}")
print(f"Content-based Item Similarity [0,1]: {content_similarity[0, 1]:.4f}")
# 5. Hybrid Recommendation System
print("\n=== Hybrid Recommendation System ===")
class HybridRecommender:
Установить Recommendation Engine в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл Recommendation Engine?
Build recommendation systems using collaborative filtering, content-based filtering, matrix factorization, and neural network approaches
Как установить скилл Recommendation Engine?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл Recommendation Engine запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic