Context Aware
ContextAwareRecommender
A context-aware recommender system that adapts recommendations based on contextual factors.
This recommender system incorporates contextual information to provide more relevant recommendations by adjusting feature weights based on the current context. It considers various contextual factors such as time, location, user state, and other environmental variables to modify the importance of different item features.
Attributes:
Name | Type | Description |
---|---|---|
context_factors |
Dict[str, Dict]
|
Mapping of context factors to their value-specific weights. Format: { "factor_name": { "value": { "feature": weight } } } |
item_features |
Dict[int, Dict]
|
Mapping of item IDs to their feature dictionaries. Format: { item_id: { "feature_name": value } } |
feature_weights |
Dict[str, float]
|
Current active feature weights based on context. |
Methods:
Name | Description |
---|---|
update_context |
Updates the current context and recalculates feature weights. |
recommend |
Generates recommendations considering the current context. |
_initialize_feature_weights |
Initializes weights based on context. |
_encode_item_features |
Encodes and weights item features. |
Source code in engines/contentFilterEngine/context_personalization/context_aware.py
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 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
|
__init__(context_config_path, item_features)
Initialize the context-aware recommender with a configuration file for context factors and item features.
Parameters: - context_config_path (str): Path to the JSON configuration file for context factors and weights. - item_features (dict): A dictionary of item features.
Source code in engines/contentFilterEngine/context_personalization/context_aware.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
|
fit(data)
Train the recommender system by building user profiles based on their interactions.
Parameters: - data (dict): The data used for training the model, containing user interactions.
Source code in engines/contentFilterEngine/context_personalization/context_aware.py
139 140 141 142 143 144 145 146 147 148 149 150 |
|
recommend(user_id, context=None, top_n=10)
Generate top-N item recommendations for a given user considering context.
Parameters: - user_id (int): The ID of the user. - context (dict, optional): The current context to consider. If provided, updates context factors. - top_n (int): The number of recommendations to generate.
Returns: - List[int]: List of recommended item IDs.
Source code in engines/contentFilterEngine/context_personalization/context_aware.py
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
|