Skip to content

Commit 88a25d8

Browse files
author
Kenneth Chan
committed
Merge tag 'v0.6.0'
v0.6.0 release
2 parents 554d957 + 39772ea commit 88a25d8

File tree

8 files changed

+484
-139
lines changed

8 files changed

+484
-139
lines changed

docs/source/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@
4949
# built documents.
5050
#
5151
# The short X.Y version.
52-
version = '0.5'
52+
version = '0.6'
5353
# The full version, including alpha/beta/rc tags.
54-
release = '0.5.0'
54+
release = '0.6.0'
5555

5656
# The language for content autogenerated by Sphinx. Refer to documentation
5757
# for a list of supported languages.

docs/source/predictionio.rst

Lines changed: 154 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Afterwards, you can import data or retrieve recommendations for your App by call
2828

2929
>>> client.create_user("u100", { "pio_latlng" : [1.23, 4.56], "custom": "value" })
3030

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.
3232

3333
**Item**
3434

@@ -38,13 +38,13 @@ Afterwards, you can import data or retrieve recommendations for your App by call
3838

3939
To import an item record with the predefined optional attribute "pio_latlng":
4040

41-
>>> client.create_user("i200", ("type3",), { "pio_latlng" : [1.23, 4.56] })
41+
>>> client.create_item("i200", ("type3",), { "pio_latlng" : [1.23, 4.56] })
4242

4343
You may also define your own custom attribute "custom" = "value":
4444

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" })
4646

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.
4848

4949
**User Action on Item**
5050

@@ -63,15 +63,21 @@ Afterwards, you can import data or retrieve recommendations for your App by call
6363

6464
>>> client.record_action_on_item("like", "i200", { "pio_t": 12345678 })
6565

66-
.. note:: predifined actions: "like", "dislike", "rate", "view", "conversion"
66+
.. note:: predefined actions: "like", "dislike", "rate", "view", "conversion"
6767

68-
**Item Recommendation**
68+
**Item Recommendation Engine**
6969

7070
When there is enough data imported from your App and the prediction results are ready, you can get recommendations for a user.
7171

7272
To get top 5 item recommendation for the same user id from the item recommendation engine "engine-1"
7373

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)
7581

7682
Please refer to the documentation of the :class:`predictionio.Client` class for more details of all available methods.
7783

@@ -114,7 +120,7 @@ This allows you to do other work between these two steps.
114120
For example, the following code first generates an asynchronous request to retrieve recommendations, then get the result at later time::
115121

116122
>>> # 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)
118124
>>> <...you can do other things here...>
119125
>>> try:
120126
>>> 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
129135

130136
For example, to import 100000 of user records::
131137

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>
145151

146152
Alternatively, you can use blocking requests to import large amount of data, but this has significantly lower performance::
147153

@@ -159,77 +165,150 @@ predictionio.Client Class
159165

160166
.. Autoclass:: Client
161167

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
163270

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
169272

170-
.. note::
273+
.. versionadded:: 0.5.0
171274

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.
181277

182-
.. automethod:: close
183-
.. automethod:: identify
278+
.. automethod:: aget_itemsim_topn
184279

185-
|
280+
.. versionadded:: 0.6.0
186281

187-
.. _sync-methods-label:
282+
.. automethod:: aget_itemrec
188283

189-
.. note:: The following is blocking (synchronous) request methods
284+
.. deprecated:: 0.5.0
285+
Use :func:`aget_itemrec_topn` instead.
190286

191-
.. automethod:: get_status
192-
.. automethod:: create_user
193-
.. automethod:: get_user
194-
.. automethod:: delete_user
287+
.. automethod:: auser_conversion_item
195288

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.
199291

200-
.. automethod:: get_itemrec_topn
201-
.. automethod:: record_action_on_item
292+
.. automethod:: auser_dislike_item
202293

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.
209296

210-
|
297+
.. automethod:: auser_like_item
211298

212-
.. _async-methods-label:
299+
.. deprecated:: 0.5.0
300+
Use :func:`arecord_action_on_item` instead.
213301

214-
.. note:: The following is non-blocking (asynchronous) request methods
302+
.. automethod:: auser_rate_item
215303

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.
219306

220-
.. automethod:: acreate_item
221-
.. automethod:: aget_item
222-
.. automethod:: adelete_item
307+
.. automethod:: auser_view_item
223308

224-
.. automethod:: aget_itemrec_topn
225-
.. automethod:: arecord_action_on_item
309+
.. deprecated:: 0.5.0
310+
Use :func:`arecord_action_on_item` instead.
226311

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
234313

235314

examples/itemrec/movies/movie_rec_app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def recommend_task(self, prev_state):
5555
print "[Info] Getting top %s item recommendations for user %s..." % (n, u.uid)
5656
try:
5757
self._client.identify(u.uid)
58-
rec = self._client.get_itemrec_topn(n, ENGINE_NAME)
58+
rec = self._client.get_itemrec_topn(ENGINE_NAME, n)
5959
u.rec = rec['pio_iids']
6060
self.display_items(u.rec)
6161
except predictionio.ItemRecNotFoundError:

0 commit comments

Comments
 (0)