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
In the Azure portal, in the Personalizer resource on the **Configuration** page, change the **Model update frequency** to 10 seconds. This short duration will train the service rapidly, allowing you to see how the top action changes for each iteration.
17
+
18
+

19
+
20
+
When a Personalizer loop is first instantiated, there is no model since there has been no Reward API calls to train from. Rank calls will return equal probabilities for each item. Your application should still always rank content using the output of RewardActionId.
Create a resource for Personalizer using the [Azure portal](https://docs.microsoft.com/azure/cognitive-services/cognitive-services-apis-create-account) or [Azure CLI](https://docs.microsoft.com/azure/cognitive-services/cognitive-services-apis-create-account-cli) on your local machine. You can also:
17
+
18
+
* Get a [trial key](https://azure.microsoft.com/try/cognitive-services) valid for 7 days for free. After signing up, it will be available on the [Azure website](https://azure.microsoft.com/try/cognitive-services/my-apis/).
19
+
* View your resource on the [Azure portal](https://portal.azure.com/).
20
+
21
+
After you get a key from your trial subscription or resource, create two [environment variable](https://docs.microsoft.com/azure/cognitive-services/cognitive-services-apis-create-account#configure-an-environment-variable-for-authentication):
22
+
23
+
*`PERSONALIZER_RESOURCE_KEY` for the resource key.
24
+
*`PERSONALIZER_RESOURCE_ENDPOINT` for the resource endpoint.
25
+
26
+
In the Azure portal, both the key and endpoint values are available from the **quickstart** page.
Copy file name to clipboardExpand all lines: articles/cognitive-services/personalizer/includes/quickstart-sdk-csharp.md
+16-34Lines changed: 16 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,32 +23,14 @@ ms.author: diberry
23
23
There are several steps to use this quickstart:
24
24
25
25
* In the Azure portal, create a Personalizer resource
26
-
* In the Azure portal, for the Personalizer resource, on the **Configuration** page, change the model update frequency
26
+
* In the Azure portal, for the Personalizer resource, on the **Configuration** page, change the model update frequency to a very short interval
27
27
* In a code editor, create a code file and edit the code file
28
28
* In the command line or terminal, install the SDK from the command line
29
29
* In the command line or terminal, run the code file
30
30
31
-
## Create a Personalizer Azure resource
31
+
[!INCLUDE [Create Azure resource for Personalizer](create-personalizer-resource.md)]
32
32
33
-
Create a resource for Personalizer using the [Azure portal](https://docs.microsoft.com/azure/cognitive-services/cognitive-services-apis-create-account) or [Azure CLI](https://docs.microsoft.com/azure/cognitive-services/cognitive-services-apis-create-account-cli) on your local machine. You can also:
34
-
35
-
* Get a [trial key](https://azure.microsoft.com/try/cognitive-services) valid for 7 days for free. After signing up, it will be available on the [Azure website](https://azure.microsoft.com/try/cognitive-services/my-apis/).
36
-
* View your resource on the [Azure portal](https://portal.azure.com/).
37
-
38
-
After you get a key from your trial subscription or resource, create two [environment variable](https://docs.microsoft.com/azure/cognitive-services/cognitive-services-apis-create-account#configure-an-environment-variable-for-authentication):
39
-
40
-
*`PERSONALIZER_RESOURCE_KEY` for the resource key.
41
-
*`PERSONALIZER_RESOURCE_ENDPOINT` for the resource endpoint.
42
-
43
-
In the Azure portal, both the key and endpoint values are available from the **quickstart** page.
44
-
45
-
## Change the model update frequency
46
-
47
-
In the Azure portal, in the Personalizer resource on the **Configuration** page, change the **Model update frequency** to 10 seconds. This short duration will train the service rapidly, allowing you to see how the top action changes for each iteration.
48
-
49
-

50
-
51
-
When a Personalizer loop is first instantiated, there is no model since there has been no Reward API calls to train from. Rank calls will return equal probabilities for each item. Your application should still always rank content using the output of RewardActionId.
33
+
[!INCLUDE [!Change model frequency](change-model-frequency.md)]
52
34
53
35
## Create a new C# application
54
36
@@ -90,19 +72,19 @@ If you're using the Visual Studio IDE, the client library is available as a down
90
72
91
73
The Personalizer client is a [PersonalizerClient](https://docs.microsoft.com/dotnet/api/microsoft.azure.cognitiveservices.personalizer.personalizerclient?view=azure-dotnet) object that authenticates to Azure using Microsoft.Rest.ServiceClientCredentials, which contains your key.
92
74
93
-
To ask for a rank of the content, create a [RankRequest](https://docs.microsoft.com/dotnet/api/microsoft.azure.cognitiveservices.personalizer.models.rankrequest?view=azure-dotnet-preview), then pass it to [client.Rank](https://docs.microsoft.com/dotnet/api/microsoft.azure.cognitiveservices.personalizer.personalizerclientextensions.rank?view=azure-dotnet-preview) method. The Rank method returns a RankResponse, containing the ranked content.
75
+
To ask for the single best item of the content, create a [RankRequest](https://docs.microsoft.com/dotnet/api/microsoft.azure.cognitiveservices.personalizer.models.rankrequest?view=azure-dotnet-preview), then pass it to [client.Rank](https://docs.microsoft.com/dotnet/api/microsoft.azure.cognitiveservices.personalizer.personalizerclientextensions.rank?view=azure-dotnet-preview) method. The Rank method returns a RankResponse.
94
76
95
-
To send a reward to Personalizer, create a [RewardRequest](https://docs.microsoft.com/dotnet/api/microsoft.azure.cognitiveservices.personalizer.models.rewardrequest?view=azure-dotnet-preview), then pass it to the [client.Reward](https://docs.microsoft.com/dotnet/api/microsoft.azure.cognitiveservices.personalizer.personalizerclientextensions.reward?view=azure-dotnet-preview) method.
77
+
To send a reward score to Personalizer, create a [RewardRequest](https://docs.microsoft.com/dotnet/api/microsoft.azure.cognitiveservices.personalizer.models.rewardrequest?view=azure-dotnet-preview), then pass it to the [client.Reward](https://docs.microsoft.com/dotnet/api/microsoft.azure.cognitiveservices.personalizer.personalizerclientextensions.reward?view=azure-dotnet-preview) method.
96
78
97
-
Determining the reward, in this quickstart is trivial. In a production system, the determination of what impacts the [reward score](../concept-rewards.md) and by how much can be a complex process, that you may decide to change over time. This design decision should be one of the primary decisions in your Personalizer architecture.
79
+
Determining the reward score, in this quickstart is trivial. In a production system, the determination of what impacts the [reward score](../concept-rewards.md) and by how much can be a complex process, that you may decide to change over time. This design decision should be one of the primary decisions in your Personalizer architecture.
98
80
99
81
## Code examples
100
82
101
83
These code snippets show you how to do the following tasks with the Personalizer client library for .NET:
102
84
103
85
*[Create a Personalizer client](#create-a-personalizer-client)
104
-
*[Request a rank](#request-a-rank)
105
-
*[Send a reward](#send-a-reward)
86
+
*[Rank API](#request-the-best-action)
87
+
*[Reward API](#send-a-reward)
106
88
107
89
## Add the dependencies
108
90
@@ -124,13 +106,13 @@ Next, create a method to return a Personalizer client. The parameter to the meth
124
106
125
107
## Get food items as rankable actions
126
108
127
-
Actions represent the content choices you want Personalizer to rank. Add the following methods to the Program class to represent the set of actions to rank.
109
+
Actions represent the content choices from which you want Personalizer to select the best content item. Add the following methods to the Program class to represent the set of actions and their features.
128
110
129
111
[!code-csharp[Food items as actions](~/samples-personalizer/quickstarts/csharp/PersonalizerExample/Program.cs?name=createAction)]
130
112
131
113
## Get user preferences for context
132
114
133
-
Add the following methods to the Program class to get a user's input from the command line for the time of day and current food preference. These will be uses as context when ranking the actions.
115
+
Add the following methods to the Program class to get a user's input from the command line for the time of day and current food preference. These will be used as context features.
134
116
135
117
[!code-csharp[Present time out day preference to the user](~/samples-personalizer/quickstarts/csharp/PersonalizerExample/Program.cs?name=createUserFeatureTimeOfDay)]
136
118
@@ -142,9 +124,9 @@ Both methods use the `GetKey` method to read the user's selection from the comma
142
124
143
125
## Create the learning loop
144
126
145
-
The Personalizer learning loop is a cycle of rank and reward calls. In this quickstart, each rank call, to personalize the content, is followed by a reward call to tell Personalizer how well the service ranked the content.
127
+
The Personalizer learning loop is a cycle of [Rank](#request-the-best-action) and [Reward](#send-a-reward) calls. In this quickstart, each Rank call, to personalize the content, is followed by a Reward call to tell Personalizer how well the service performed.
146
128
147
-
The following code in the `main` method of the program loops through a cycle of asking the user their preferences at the command line, sending that information to Personalizer to rank, presenting the ranked selection to the customer to choose from among the list, then sending a reward to Personalizer signaling how well the service did in ranking the selection.
129
+
The following code loops through a cycle of asking the user their preferences at the command line, sending that information to Personalizer to select the best action, presenting the selection to the customer to choose from among the list, then sending a reward score to Personalizer signaling how well the service did in its selection.
@@ -155,19 +137,19 @@ Add the following methods, which [get the content choices](#get-food-items-as-ra
155
137
*`GetUsersTastePreference`
156
138
*`GetKey`
157
139
158
-
## Request a rank
140
+
## Request the best action
159
141
160
-
To complete the rank request, the program asks the user's preferences to create a `currentContent` of the content choices. The process can create content to exclude from the rank, shown as `excludeActions`. The rank request needs the actions, currentContext, excludeActions, and a unique rank event ID (as a GUID), to receive the ranked response.
142
+
To complete the Rank request, the program asks the user's preferences to create a `currentContent` of the content choices. The process can create content to exclude from the actions, shown as `excludeActions`. The Rank request needs the actions and their features, currentContext features, excludeActions, and a unique event ID, to receive the response.
161
143
162
144
This quickstart has simple context features of time of day and user food preference. In production systems, determining and [evaluating](../concept-feature-evaluation.md)[actions and features](../concepts-features.md) can be a non-trivial matter.
163
145
164
146
[!code-csharp[The Personalizer learning loop ranks the request.](~/samples-personalizer/quickstarts/csharp/PersonalizerExample/Program.cs?name=rank)]
165
147
166
148
## Send a reward
167
149
168
-
To complete the reward request, the program gets the user's selection from the command line, assigns a numeric value to each selection, then sends the unique rank event ID and the numeric value to the reward method.
150
+
To get the reward score to send in the Reward request, the program gets the user's selection from the command line, assigns a numeric value to the selection, then sends the unique event ID and the reward score as the numeric value to the Reward API.
169
151
170
-
This quickstart assigns a simple number as a reward, either a zero or a 1. In production systems, determining when and what to send to the [reward](../concept-rewards.md) call can be a non-trivial matter, depending on your specific needs.
152
+
This quickstart assigns a simple number as a reward score, either a zero or a 1. In production systems, determining when and what to send to the [Reward](../concept-rewards.md) call can be a non-trivial matter, depending on your specific needs.
171
153
172
154
[!code-csharp[The Personalizer learning loop ranks the request.](~/samples-personalizer/quickstarts/csharp/PersonalizerExample/Program.cs?name=reward)]
0 commit comments