Ranking from User Attributes
Providing personalized recommendations for new users who lack interaction history presents a classic cold-start problem. Shaped tackles this challenge by enabling you to leverage user attributes for generating relevant recommendations even before a user has engaged with your platform.
Introducing user_features
in the Rank API
The user_features
argument in the Rank API allows you to provide a dictionary of user attributes, empowering you to:
- Personalize onboarding experiences: Recommend items aligned with a new user's stated interests or preferences collected during signup.
- Target specific user segments: Generate recommendations tailored to users with particular demographic or behavioral characteristics.
- Handle anonymous sessions: Provide relevant recommendations even when a user ID is not available, using contextual information.
Here's how it works:
- JavaScript
- Python
- CLI
npm install @shaped.ai/client
const shapedai = require('@shaped.ai/client');
async function trendingItems() {
const client = shapedai.Client('your_api_key');
const model_name = 'for_you_feed_v1';
const user_features = {
"country": "US",
"interests": ["technology", "travel", "food"],
"language": "en"
}
const limit = 5;
const results = await client.rank({model_name, user_features, limit});
}
pip install shaped
import shaped
api_key = 'your_api_key'
client = shaped.Client(api_key=api_key)
user_features = {
"country": "US",
"interests": ["technology", "travel", "food"],
"language": "en"
}
results = client.rank(
model_name='for_you_feed_v1',
user_features,
limit=5,
)
pip install shaped
user_features = {
"country": "US",
"interests": ["technology", "travel", "food"],
"language": "en"
}
shaped rank --model_name my_recommendation_model \
--user_features "$user_features"
In this example, we're providing user attributes related to location, interests, and language. Shaped uses this information to generate personalized recommendations even though a user_id
wasn't provided.
How Shaped Handles user_features
:
Shaped employs two primary approaches to deliver relevant recommendations using user_features
:
1. Similarity-Based Matching
When you provide user_features
, Shaped can:
- Identify Similar Users: Search for existing users in your data with matching or similar attribute profiles.
- Transfer Preferences: Leverage the interaction history and preferences of these similar users to generate recommendations for the new user.
This approach is particularly effective when you have a well-populated user base with diverse attribute profiles, allowing Shaped to find meaningful matches and transfer preferences effectively.
2. Direct Attribute-Item Relationships
Shaped's models also learn direct relationships between user attributes and item relevance during training. This means that even without finding a direct match in the user catalog, Shaped can:
- Interpret Attribute Signals: Analyze the provided
user_features
and their relationship to item preferences observed during training. - Predict Relevant Items: Generate recommendations based on the learned association between specific attributes and item preferences.
This approach is valuable when dealing with niche interests or attribute combinations that might not have many exact matches within your user base.
Conclusion
The user_features
argument provides a powerful mechanism to personalize recommendations for new or anonymous users. By intelligently leveraging both similarity-based matching and learned attribute-item relationships, Shaped ensures relevant and engaging recommendations even in cold-start scenarios, enhancing the user experience from the very beginning.