You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/cognitive-services/personalizer/concepts-features.md
+21-40Lines changed: 21 additions & 40 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,20 +11,10 @@ ms.topic: conceptual
11
11
ms.date: 10/25/2022
12
12
---
13
13
14
-
# Context and Actions
14
+
# Context and actions
15
15
16
16
Personalizer works by learning what your application should show to users in a given context. These are the two most important pieces of information that you pass into Personalizer. The **context** represents the information you have about the current user or the state of your system, and the **actions** are the options to be chosen from.
17
17
18
-
## Table of Contents
19
-
20
-
*[Context](#context) Information about the current user or state of the system
21
-
*[Actions](#actions) A list of options to choose from
22
-
*[Features](#features) Attributes describing the Context and Actions
23
-
*[Feature Engineering](#feature-engineering) Tips for constructing impactful features
24
-
*[Namespaces](#namespaces) Grouping Features
25
-
*[Examples](#json-examples) Examples of Context and Action features in JSON format
26
-
27
-
28
18
## Context
29
19
30
20
Information for the _context_ depends on each application and use case, but it typically may include information such as:
@@ -34,18 +24,16 @@ Information for the _context_ depends on each application and use case, but it t
34
24
* Information about the current time, such as day of the week, weekend or not, morning or afternoon, holiday season or not, etc.
35
25
* Information extracted from mobile applications, such as location, movement, or battery level.
36
26
* Historical aggregates of the behavior of users - such as what are the movie genres this user has viewed the most.
37
-
* Information about the state of the system.
27
+
* Information about the state of the system.
38
28
39
29
Your application is responsible for loading the information about the context from the relevant databases, sensors, and systems you may have. If your context information doesn't change, you can add logic in your application to cache this information, before sending it to the Rank API.
40
30
41
-
42
31
## Actions
43
32
44
33
Actions represent a list of options.
45
34
46
35
Don't send in more than 50 actions when Ranking actions. These may be the same 50 actions every time, or they may change. For example, if you have a product catalog of 10,000 items for an e-commerce application, you may use a recommendation or filtering engine to determine the top 40 a customer may like, and use Personalizer to find the one that will generate the most reward (for example, the user will add to the basket) for the current context.
47
36
48
-
49
37
### Examples of actions
50
38
51
39
The actions you send to the Rank API will depend on what you are trying to personalize.
@@ -61,18 +49,15 @@ Here are some examples:
61
49
|Choose a chat bot's response to clarify user intent or suggest an action.|Each action is an option of how to interpret the response.|
62
50
|Choose what to show at the top of a list of search results|Each action is one of the top few search results.|
63
51
64
-
65
52
### Load actions from the client application
66
53
67
54
Features from actions may typically come from content management systems, catalogs, and recommender systems. Your application is responsible for loading the information about the actions from the relevant databases and systems you have. If your actions don't change or getting them loaded every time has an unnecessary impact on performance, you can add logic in your application to cache this information.
68
55
69
-
70
56
### Prevent actions from being ranked
71
57
72
58
In some cases, there are actions that you don't want to display to users. The best way to prevent an action from being ranked is by adding it to the [Excluded Actions](https://learn.microsoft.com/dotnet/api/microsoft.azure.cognitiveservices.personalizer.models.rankrequest.excludedactions) list, or not passing it to the Rank Request.
73
59
74
-
In some cases, you might not want events to be trained on by default, i.e., you only want to train events when a specific condition is met. For example, The personalized part of your webpage is below the fold (users have to scroll before interacting with the personalized content). In this case you will render the entire page, but only want an event to be trained on when the user scrolls and has a chance to interact with the personalized content. For these cases, you should [Defer Event Activation](concept-active-inactive-events.md) to avoid assigning default reward (and training) events which the end user did not have a chance to interact with.
75
-
60
+
In some cases, you might not want events to be trained on by default. In other words, you only want to train events when a specific condition is met. For example, The personalized part of your webpage is below the fold (users have to scroll before interacting with the personalized content). In this case you will render the entire page, but only want an event to be trained on when the user scrolls and has a chance to interact with the personalized content. For these cases, you should [Defer Event Activation](concept-active-inactive-events.md) to avoid assigning default reward (and training) events which the end user did not have a chance to interact with.
76
61
77
62
## Features
78
63
@@ -91,14 +76,14 @@ Personalizer does not prescribe, limit, or fix what features you can send for ac
91
76
92
77
It's ok and natural for features to change over time. However, keep in mind that Personalizer's machine learning model adapts based on the features it sees. If you send a request containing all new features, Personalizer's model will not be able to leverage past events to select the best action for the current event. Having a 'stable' feature set (with recurring features) will help the performance of Personalizer's machine learning algorithms.
93
78
94
-
### Context Features
79
+
### Context features
95
80
* Some context features may only be available part of the time. For example, if a user is logged into the online grocery store website, the context will contain features describing purchase history. These features will not be available for a guest user.
96
81
* There must be at least one context feature. Personalizer does not support an empty context.
97
82
* If the context features are identical for every request, Personalizer will choose the globally best action.
98
83
99
-
### Action Features
84
+
### Action features
100
85
* Not all actions need to contain the same features. For example, in the online grocery store scenario, microwavable popcorn will have a "cooking time" feature, while a cucumber will not.
101
-
* Features for a certain action ID may be available one day, but later on become unavailable.
86
+
* Features for a certain action ID may be available one day, but later on become unavailable.
102
87
103
88
Examples:
104
89
@@ -112,17 +97,16 @@ The following are good examples for action features. These will depend a lot on
112
97
113
98
Personalizer supports features of string, numeric, and boolean types. It's very likely that your application will mostly use string features, with a few exceptions.
114
99
115
-
### How feature types affects the Machine Learning in Personalizer
100
+
### How feature types affect machine learning in Personalizer
116
101
117
-
***Strings**: For string types, every key-value (feature name, feature value) combination is treated as a One-Hot feature (e.g. category:"Produce" and category:"Meat" would internally be represented as different features in the machine learning model.
102
+
***Strings**: For string types, every key-value (feature name, feature value) combination is treated as a One-Hot feature (for example, category:"Produce" and category:"Meat" would internally be represented as different features in the machine learning model).
118
103
***Numeric**: Only use numeric values when the number is a magnitude that should proportionally affect the personalization result. This is very scenario dependent. Features that are based on numeric units but where the meaning isn't linear - such as Age, Temperature, or Person Height - are best encoded as categorical strings. For example Age could be encoded as "Age":"0-5", "Age":"6-10", etc. Height could be bucketed as "Height": "<5'0", "Height": "5'0-5'4", "Height": "5'5-5'11", "Height":"6'0-6-4", "Height":">6'4".
119
104
***Boolean**
120
-
***Arrays** ONLY numeric arrays are supported.
121
-
105
+
***Arrays** Only numeric arrays are supported.
122
106
123
-
## Feature Engineering
107
+
## Feature engineering
124
108
125
-
* Use categorical and string types for features that are not a magnitude.
109
+
* Use categorical and string types for features that are not a magnitude.
126
110
* Make sure there are enough features to drive personalization. The more precisely targeted the content needs to be, the more features are needed.
127
111
* There are features of diverse *densities*. A feature is *dense* if many items are grouped in a few buckets. For example, thousands of videos can be classified as "Long" (over 5 min long) and "Short" (under 5 min long). This is a *very dense* feature. On the other hand, the same thousands of items can have an attribute called "Title", which will almost never have the same value from one item to another. This is a very non-dense or *sparse* feature.
128
112
@@ -134,21 +118,21 @@ Having features of high density helps Personalizer extrapolate learning from one
134
118
***Sending user IDs** With large numbers of users, it's unlikely that this information is relevant to Personalizer learning to maximize the average reward score. Sending user IDs (even if non-PII) will likely add more noise to the model and is not recommended.
135
119
***Sending unique values that will rarely occur more than a few times**. It's recommended to bucket your features to a higher level-of-detail. For example, having features such as `"Context.TimeStamp.Day":"Monday"` or `"Context.TimeStamp.Hour":13` can be useful as there are only 7 and 24 unique values, respectively. However, `"Context.TimeStamp":"1985-04-12T23:20:50.52Z"` is very precise and has an extremely large number of unique values, which makes it very difficult for Personalizer to learn from it.
136
120
137
-
### Improve feature sets
121
+
### Improve feature sets
138
122
139
123
Analyze the user behavior by running a [Feature Evaluation Job](how-to-feature-evaluation.md). This allows you to look at past data to see what features are heavily contributing to positive rewards versus those that are contributing less. You can see what features are helping, and it will be up to you and your application to find better features to send to Personalizer to improve results even further.
140
124
141
125
### Expand feature sets with artificial intelligence and cognitive services
142
126
143
-
Artificial Intelligence and ready-to-run Cognitive Services can be a very powerful addition to Personalizer.
127
+
Artificial Intelligence and ready-to-run Cognitive Services can be a very powerful addition to Personalizer.
144
128
145
129
By preprocessing your items using artificial intelligence services, you can automatically extract information that is likely to be relevant for personalization.
146
130
147
131
For example:
148
132
149
-
* You can run a movie file via [Video Indexer](https://azure.microsoft.com/services/media-services/video-indexer/) to extract scene elements, text, sentiment, and many other attributes. These attributes can then be made more dense to reflect characteristics that the original item metadata didn't have.
133
+
* You can run a movie file via [Video Indexer](https://azure.microsoft.com/services/media-services/video-indexer/) to extract scene elements, text, sentiment, and many other attributes. These attributes can then be made more dense to reflect characteristics that the original item metadata didn't have.
150
134
* Images can be run through object detection, faces through sentiment, etc.
151
-
* Information in text can be augmented by extracting entities, sentiment, expanding entities with Bing knowledge graph, etc.
135
+
* Information in text can be augmented by extracting entities, sentiment, and expanding entities with Bing knowledge graph.
152
136
153
137
You can use several other [Azure Cognitive Services](https://www.microsoft.com/cognitive-services), like
154
138
@@ -157,17 +141,16 @@ You can use several other [Azure Cognitive Services](https://www.microsoft.com/c
Embeddings from various Machine Learning models have proven to be affective features for Personalizer
163
147
164
148
* Embeddings from Large Language Models
165
149
* Embeddings from Computer Vision Models
166
150
167
-
168
151
## Namespaces
169
152
170
-
Optionally, features can be organized using namespaces (relevant for both context and action features). Namespaces can be used to group features by topic, by source, or any other grouping that makes sense in your application. You determine if namespaces are used and what they should be. Namespaces organize features into distinct sets, and disambiguate features with similar names. You can think of namespaces as a 'prefix' that is added to feature names. Namespaces should not be nested.
153
+
Optionally, features can be organized using namespaces (relevant for both context and action features). Namespaces can be used to group features by topic, by source, or any other grouping that makes sense in your application. You determine if namespaces are used and what they should be. Namespaces organize features into distinct sets, and disambiguate features with similar names. You can think of namespaces as a 'prefix' that is added to feature names. Namespaces should not be nested.
171
154
172
155
The following are examples of feature namespaces used by applications:
173
156
@@ -191,13 +174,12 @@ The following are examples of feature namespaces used by applications:
191
174
* The following characters cannot be used: codes < 32 (not printable), 32 (space), 58 (colon), 124 (pipe), and 126–140.
192
175
* All namespaces starting with an underscore `_` will be ignored.
193
176
194
-
195
-
## JSON Examples
177
+
## JSON examples
196
178
197
179
### Actions
198
180
When calling Rank, you will send multiple actions to choose from:
199
181
200
-
JSON objects can include nested JSON objects and simple property/values. An array can be included only if the array items are numbers.
182
+
JSON objects can include nested JSON objects and simple property/values. An array can be included only if the array items are numbers.
201
183
202
184
```json
203
185
{
@@ -266,7 +248,7 @@ JSON objects can include nested JSON objects and simple property/values. An arra
266
248
267
249
Context is expressed as a JSON object that is sent to the Rank API:
268
250
269
-
JSON objects can include nested JSON objects and simple property/values. An array can be included only if the array items are numbers.
251
+
JSON objects can include nested JSON objects and simple property/values. An array can be included only if the array items are numbers.
270
252
271
253
```JSON
272
254
{
@@ -290,12 +272,11 @@ JSON objects can include nested JSON objects and simple property/values. An arra
290
272
291
273
### Namespaces
292
274
293
-
In the following JSON, `user`, `environment`, `device`, and `activity` are namespaces.
275
+
In the following JSON, `user`, `environment`, `device`, and `activity` are namespaces.
294
276
295
277
> [!Note]
296
278
> We strongly recommend using names for feature namespaces that are UTF-8 based and start with different letters. For example, `user`, `environment`, `device`, and `activity` start with `u`, `e`, `d`, and `a`. Currently having namespaces with same first characters could result in collisions.
0 commit comments