@@ -28,7 +28,7 @@ Afterwards, you can import data or retrieve recommendations for your App by call
28
28
29
29
>>> client.create_user(" u100" , { " pio_latlng" : [1.23 , 4.56 ], " custom" : " value" })
30
30
31
- .. note :: custom attributes and values could be any string but all attribute names with prefix " pio_" are reserved. You should not use the prefix " pio_" when define your custom attributes to avoid conflicts.
31
+ .. note :: custom attributes and values could be any string but all attribute names with prefix ``' pio_'`` are reserved. You should not use the prefix ``' pio_'`` when define your custom attributes to avoid conflicts.
32
32
33
33
**Item **
34
34
@@ -38,13 +38,13 @@ Afterwards, you can import data or retrieve recommendations for your App by call
38
38
39
39
To import an item record with the predefined optional attribute "pio_latlng":
40
40
41
- >>> client.create_user (" i200" , (" type3" ,), { " pio_latlng" : [1.23 , 4.56 ] })
41
+ >>> client.create_item (" i200" , (" type3" ,), { " pio_latlng" : [1.23 , 4.56 ] })
42
42
43
43
You may also define your own custom attribute "custom" = "value":
44
44
45
- >>> client.create_user (" i200" , (" type3" ,), { " pio_latlng" : [1.23 , 4.56 ], " custom" : " value" })
45
+ >>> client.create_item (" i200" , (" type3" ,), { " pio_latlng" : [1.23 , 4.56 ], " custom" : " value" })
46
46
47
- .. note :: custom attributes and values could be any string but all attribute names with prefix " pio_" are reserved. You should not use the prefix " pio_" when define your custom attributes to avoid conflicts.
47
+ .. note :: custom attributes and values could be any string but all attribute names with prefix ``' pio_'`` are reserved. You should not use the prefix ``' pio_'`` when define your custom attributes to avoid conflicts.
48
48
49
49
**User Action on Item **
50
50
@@ -63,15 +63,21 @@ Afterwards, you can import data or retrieve recommendations for your App by call
63
63
64
64
>>> client.record_action_on_item(" like" , " i200" , { " pio_t" : 12345678 })
65
65
66
- .. note :: predifined actions: "like", "dislike", "rate", "view", "conversion"
66
+ .. note :: predefined actions: "like", "dislike", "rate", "view", "conversion"
67
67
68
- **Item Recommendation **
68
+ **Item Recommendation Engine **
69
69
70
70
When there is enough data imported from your App and the prediction results are ready, you can get recommendations for a user.
71
71
72
72
To get top 5 item recommendation for the same user id from the item recommendation engine "engine-1"
73
73
74
- >>> result = client.get_itemrec_topn(5 , " engine-1" )
74
+ >>> result = client.get_itemrec_topn(" engine-1" , 5 )
75
+
76
+ **Item Similarity Engine **
77
+
78
+ To get top 5 similar items of the item i200 from the item similarity engine "engine-2"
79
+
80
+ >>> result = client.get_itemsim_topn(" engine-2" , " i200" , 5 )
75
81
76
82
Please refer to the documentation of the :class: `predictionio.Client ` class for more details of all available methods.
77
83
@@ -114,7 +120,7 @@ This allows you to do other work between these two steps.
114
120
For example, the following code first generates an asynchronous request to retrieve recommendations, then get the result at later time::
115
121
116
122
>>> # Generates asynchronous request and return an AsyncRequest object
117
- >>> request = client.aget_itemrec_topn(5, "engine-1")
123
+ >>> request = client.aget_itemrec_topn("engine-1", 5 )
118
124
>>> <...you can do other things here...>
119
125
>>> try:
120
126
>>> result = client.aresp(request) # check the request status and get the return data.
@@ -129,19 +135,19 @@ When you import large amount of data at once, you may also use asynchronous requ
129
135
130
136
For example, to import 100000 of user records::
131
137
132
- >>> # generate 100000 asynchronous requests and store the AsyncRequest objects
133
- >>> req = {}
134
- >>> for i in range(100000):
135
- >>> req[i] = client.acreate_user(user_record[i].uid)
136
- >>>
137
- >>> <...you can do other things here...>
138
- >>>
139
- >>> # now check the status of the previous asynchronous requests
140
- >>> for i in range(100000):
141
- >>> try:
142
- >>> result = client.aresp(req[i])
143
- >>> except:
144
- >>> <log the error>
138
+ >>> # generate 100000 asynchronous requests and store the AsyncRequest objects
139
+ >>> req = {}
140
+ >>> for i in range(100000):
141
+ >>> req[i] = client.acreate_user(user_record[i].uid)
142
+ >>>
143
+ >>> <...you can do other things here...>
144
+ >>>
145
+ >>> # now check the status of the previous asynchronous requests
146
+ >>> for i in range(100000):
147
+ >>> try:
148
+ >>> result = client.aresp(req[i])
149
+ >>> except:
150
+ >>> <log the error>
145
151
146
152
Alternatively, you can use blocking requests to import large amount of data, but this has significantly lower performance::
147
153
@@ -159,77 +165,150 @@ predictionio.Client Class
159
165
160
166
.. Autoclass :: Client
161
167
162
- .. note ::
168
+ .. note ::
169
+
170
+ The "threads" parameter specifies the number of connection threads to
171
+ the PredictionIO API server. Minimum is 1. The client object will spawn
172
+ out the specified number of threads. Each of them will establish a
173
+ connection with the PredictionIO API server and handle requests
174
+ concurrently.
175
+
176
+ .. note ::
177
+
178
+ If you ONLY use :ref: `blocking request methods <sync-methods-label >`,
179
+ setting "threads" to 1 is enough (higher number will not improve
180
+ anything since every request will be blocking). However, if you want
181
+ to take full advantage of
182
+ :ref: `asynchronous request methods <async-methods-label >`, you should
183
+ specify a larger number for "threads" to increase the performance of
184
+ handling concurrent requests (although setting "threads" to 1 will still
185
+ work). The optimal setting depends on your system and application
186
+ requirement.
187
+
188
+ .. automethod :: close
189
+ .. automethod :: identify
190
+
191
+ .. versionadded :: 0.5.0
192
+
193
+ |
194
+
195
+ .. _sync-methods-label :
196
+
197
+ .. note :: The following is blocking (synchronous) request methods
198
+
199
+ .. automethod :: get_status
200
+ .. automethod :: create_user
201
+ .. automethod :: get_user
202
+ .. automethod :: delete_user
203
+
204
+ .. automethod :: create_item
205
+ .. automethod :: get_item
206
+ .. automethod :: delete_item
207
+
208
+ .. automethod :: record_action_on_item
209
+
210
+ .. versionadded :: 0.5.0
211
+
212
+ .. automethod :: get_itemrec_topn
213
+
214
+ .. versionadded :: 0.5.0
215
+
216
+ .. versionchanged :: 0.6.0
217
+ Change the order of parameters.
218
+
219
+ .. automethod :: get_itemsim_topn
220
+
221
+ .. versionadded :: 0.6.0
222
+
223
+ .. automethod :: get_itemrec
224
+
225
+ .. deprecated :: 0.5.0
226
+ Use :func: `get_itemrec_topn ` instead.
227
+
228
+ .. automethod :: user_conversion_item
229
+
230
+ .. deprecated :: 0.5.0
231
+ Use :func: `record_action_on_item ` instead.
232
+
233
+ .. automethod :: user_dislike_item
234
+
235
+ .. deprecated :: 0.5.0
236
+ Use :func: `record_action_on_item ` instead.
237
+
238
+ .. automethod :: user_like_item
239
+
240
+ .. deprecated :: 0.5.0
241
+ Use :func: `record_action_on_item ` instead.
242
+
243
+ .. automethod :: user_rate_item
244
+
245
+ .. deprecated :: 0.5.0
246
+ Use :func: `record_action_on_item ` instead.
247
+
248
+ .. automethod :: user_view_item
249
+
250
+ .. deprecated :: 0.5.0
251
+ Use :func: `record_action_on_item ` instead.
252
+
253
+ |
254
+
255
+ .. _async-methods-label :
256
+
257
+ .. note :: The following is non-blocking (asynchronous) request methods
258
+
259
+ .. automethod :: acreate_user
260
+ .. automethod :: aget_user
261
+ .. automethod :: adelete_user
262
+
263
+ .. automethod :: acreate_item
264
+ .. automethod :: aget_item
265
+ .. automethod :: adelete_item
266
+
267
+ .. automethod :: arecord_action_on_item
268
+
269
+ .. versionadded :: 0.5.0
163
270
164
- The "threads" parameter specifies the number of connection threads to
165
- the PredictionIO API server. Minimum is 1. The client object will spawn
166
- out the specified number of threads. Each of them will establish a
167
- connection with the PredictionIO API server and handle requests
168
- concurrently.
271
+ .. automethod :: aget_itemrec_topn
169
272
170
- .. note ::
273
+ .. versionadded :: 0.5.0
171
274
172
- If you ONLY use :ref: `blocking request methods <sync-methods-label >`,
173
- setting "threads" to 1 is enough (higher number will not improve
174
- anything since every request will be blocking). However, if you want
175
- to take full advantage of
176
- :ref: `asynchronous request methods <async-methods-label >`, you should
177
- specify a larger number for "threads" to increase the performance of
178
- handling concurrent requests (although setting "threads" to 1 will still
179
- work). The optimal setting depends on your system and application
180
- requirement.
275
+ .. versionchanged :: 0.6.0
276
+ Change the order of parameters.
181
277
182
- .. automethod :: close
183
- .. automethod :: identify
278
+ .. automethod :: aget_itemsim_topn
184
279
185
- |
280
+ .. versionadded :: 0.6.0
186
281
187
- .. _ sync-methods-label :
282
+ .. automethod :: aget_itemrec
188
283
189
- .. note :: The following is blocking (synchronous) request methods
284
+ .. deprecated :: 0.5.0
285
+ Use :func: `aget_itemrec_topn ` instead.
190
286
191
- .. automethod :: get_status
192
- .. automethod :: create_user
193
- .. automethod :: get_user
194
- .. automethod :: delete_user
287
+ .. automethod :: auser_conversion_item
195
288
196
- .. automethod :: create_item
197
- .. automethod :: get_item
198
- .. automethod :: delete_item
289
+ .. deprecated :: 0.5.0
290
+ Use :func: `arecord_action_on_item ` instead.
199
291
200
- .. automethod :: get_itemrec_topn
201
- .. automethod :: record_action_on_item
292
+ .. automethod :: auser_dislike_item
202
293
203
- .. automethod :: get_itemrec
204
- .. automethod :: user_conversion_item
205
- .. automethod :: user_dislike_item
206
- .. automethod :: user_like_item
207
- .. automethod :: user_rate_item
208
- .. automethod :: user_view_item
294
+ .. deprecated :: 0.5.0
295
+ Use :func: `arecord_action_on_item ` instead.
209
296
210
- |
297
+ .. automethod :: auser_like_item
211
298
212
- .. _async-methods-label :
299
+ .. deprecated :: 0.5.0
300
+ Use :func: `arecord_action_on_item ` instead.
213
301
214
- .. note :: The following is non-blocking (asynchronous) request methods
302
+ .. automethod :: auser_rate_item
215
303
216
- .. automethod :: acreate_user
217
- .. automethod :: aget_user
218
- .. automethod :: adelete_user
304
+ .. deprecated :: 0.5.0
305
+ Use :func: `arecord_action_on_item ` instead.
219
306
220
- .. automethod :: acreate_item
221
- .. automethod :: aget_item
222
- .. automethod :: adelete_item
307
+ .. automethod :: auser_view_item
223
308
224
- .. automethod :: aget_itemrec_topn
225
- .. automethod :: arecord_action_on_item
309
+ .. deprecated :: 0.5.0
310
+ Use :func: ` arecord_action_on_item ` instead.
226
311
227
- .. automethod :: aget_itemrec
228
- .. automethod :: auser_conversion_item
229
- .. automethod :: auser_dislike_item
230
- .. automethod :: auser_like_item
231
- .. automethod :: auser_rate_item
232
- .. automethod :: auser_view_item
233
- .. automethod :: aresp
312
+ .. automethod :: aresp
234
313
235
314
0 commit comments