User Profiling
UserProfilingRecommender
A context-aware recommender system that builds and maintains user profiles for personalized recommendations.
This recommender system creates and maintains detailed user profiles that capture user preferences, behavior patterns, and context-dependent interactions. It uses these profiles to generate personalized recommendations that adapt to different contexts.
Attributes:
Name | Type | Description |
---|---|---|
user_profiles |
Dict[int, Dict]
|
Detailed profiles for each user containing: - Preference vectors - Historical interactions - Context-dependent behavior patterns - Long-term and short-term interests |
context_preferences |
Dict[int, Dict]
|
User preferences mapped to different contexts |
preference_evolution |
Dict[int, List]
|
Temporal evolution of user preferences |
Methods:
Name | Description |
---|---|
update_profile |
Updates user profile with new interaction data |
analyze_context_preferences |
Analyzes user preferences in different contexts |
detect_preference_shifts |
Identifies changes in user preferences over time |
recommend |
Generates personalized recommendations based on profile and context |
Example
profiler = UserProfilingRecommender() profiler.update_profile(user_id=123, interaction_data={...}, context={...}) recommendations = profiler.recommend(user_id=123, context={"location": "work"})
Note
- Profiles are automatically updated with each user interaction
- Supports both explicit (ratings) and implicit (behavior) feedback
- Implements drift detection for evolving user preferences
Source code in engines/contentFilterEngine/context_personalization/user_profiling.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
|
__init__(user_attributes=None)
Initialize the user profiling recommender with optional user attributes.
Parameters: - user_attributes (pd.DataFrame, optional): DataFrame containing user information.
Source code in engines/contentFilterEngine/context_personalization/user_profiling.py
38 39 40 41 42 43 44 45 46 |
|
fit(user_interactions)
Build user profiles based on interactions and user attributes.
Parameters: - user_interactions (dict): Dictionary mapping user IDs to lists of interacted item IDs.
Source code in engines/contentFilterEngine/context_personalization/user_profiling.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
|
recommend(user_id, all_items, top_n=10)
Generate top-N item recommendations for a given user based on their profile.
Parameters: - user_id (int): The ID of the user. - all_items (set): Set of all available item IDs. - top_n (int): The number of recommendations to generate.
Returns: - List[int]: List of recommended item IDs.
Source code in engines/contentFilterEngine/context_personalization/user_profiling.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
|