predictionio 0.7.0 → 0.7.1.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/predictionio/client.rb +63 -0
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d88cc824f559f883af0ee9f3390b1d320aef530
|
4
|
+
data.tar.gz: 993b00e00185f29e36d6b0b958dda77be4eb6cc2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6566781e604ad53a2f661d44636530180db6347a1a0402ec33ba9e58f34182377798121829a45f0d513de6d4186127c68f4605f5a995dad489fbe04dedb7c85c
|
7
|
+
data.tar.gz: d691b96f2e287488627ab6043b8db95a416ec3eaeaa669c5890ed74ed467c3b1d319fcaa05879689dfc694333abda9928f087b413fbb334ecc2f52f26ee0369d
|
data/lib/predictionio/client.rb
CHANGED
@@ -151,6 +151,9 @@ module PredictionIO
|
|
151
151
|
# Raised when ItemRec results cannot be found for a user after a synchronous API call.
|
152
152
|
class ItemRecNotFoundError < StandardError; end
|
153
153
|
|
154
|
+
# Raised when ItemRank results cannot be found for a user after a synchronous API call.
|
155
|
+
class ItemRankNotFoundError < StandardError; end
|
156
|
+
|
154
157
|
# Raised when ItemSim results cannot be found for an item after a synchronous API call.
|
155
158
|
class ItemSimNotFoundError < StandardError; end
|
156
159
|
|
@@ -531,6 +534,66 @@ module PredictionIO
|
|
531
534
|
end
|
532
535
|
end
|
533
536
|
|
537
|
+
# :category: Asynchronous Methods
|
538
|
+
# Asynchronously request to get the ranking for a user from an ItemRank engine and return a PredictionIO::AsyncResponse object immediately.
|
539
|
+
#
|
540
|
+
# Corresponding REST API method: GET /engines/itemrank/:engine/ranked
|
541
|
+
#
|
542
|
+
# See also #get_itemrank_ranked.
|
543
|
+
def aget_itemrank_ranked(engine, iids, params = {})
|
544
|
+
rparams = Hash.new
|
545
|
+
rparams["pio_appkey"] = @appkey
|
546
|
+
rparams["pio_uid"] = @apiuid
|
547
|
+
if iids.kind_of?(Array) && iids.any?
|
548
|
+
rparams["pio_iids"] = iids.join(",")
|
549
|
+
else
|
550
|
+
rparams["pio_iids"] = iids
|
551
|
+
end
|
552
|
+
if params["pio_attributes"]
|
553
|
+
if params["pio_attributes"].kind_of?(Array) && params["pio_attributes"].any?
|
554
|
+
rparams["pio_attributes"] = params["pio_attributes"].join(",")
|
555
|
+
else
|
556
|
+
rparams["pio_attributes"] = params["pio_attributes"]
|
557
|
+
end
|
558
|
+
end
|
559
|
+
@http.aget(PredictionIO::AsyncRequest.new("/engines/itemrank/#{engine}/ranked.#{@apiformat}", rparams))
|
560
|
+
end
|
561
|
+
|
562
|
+
# :category: Synchronous Methods
|
563
|
+
# Synchronously request to get the ranking for a user from an ItemRank engine and block until a response is received.
|
564
|
+
#
|
565
|
+
# See #aget_itemrank_ranked for a description of special argument handling.
|
566
|
+
#
|
567
|
+
# call-seq:
|
568
|
+
# aget_itemrank_ranked(engine, n, params = {})
|
569
|
+
# aget_itemrank_ranked(async_response)
|
570
|
+
def get_itemrank_ranked(*args)
|
571
|
+
uid_or_res = args[0]
|
572
|
+
if uid_or_res.is_a?(PredictionIO::AsyncResponse)
|
573
|
+
response = uid_or_res
|
574
|
+
else
|
575
|
+
response = aget_itemrank_ranked(*args)
|
576
|
+
end
|
577
|
+
http_response = response.get
|
578
|
+
if http_response.is_a?(Net::HTTPOK)
|
579
|
+
res = JSON.parse(http_response.body)
|
580
|
+
if response.request.params.has_key?('pio_attributes')
|
581
|
+
attributes = response.request.params['pio_attributes'].split(',')
|
582
|
+
list_of_attribute_values = attributes.map { |attrib| res[attrib] }
|
583
|
+
res["pio_iids"].zip(*list_of_attribute_values).map { |v| Hash[(['pio_iid'] + attributes).zip(v)] }
|
584
|
+
else
|
585
|
+
res["pio_iids"]
|
586
|
+
end
|
587
|
+
else
|
588
|
+
begin
|
589
|
+
msg = response.body
|
590
|
+
rescue Exception
|
591
|
+
raise ItemRankNotFoundError, response
|
592
|
+
end
|
593
|
+
raise ItemRankNotFoundError, msg
|
594
|
+
end
|
595
|
+
end
|
596
|
+
|
534
597
|
# :category: Asynchronous Methods
|
535
598
|
# Asynchronously request to get the top n similar items for an item from an ItemSim engine and return a PredictionIO::AsyncResponse object immediately.
|
536
599
|
#
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: predictionio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.1.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- The PredictionIO Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |
|
14
14
|
PredictionIO is a prediction server for building smart applications. This gem
|
@@ -38,12 +38,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
38
38
|
version: '1.9'
|
39
39
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
40
40
|
requirements:
|
41
|
-
- - '
|
41
|
+
- - '>'
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version:
|
43
|
+
version: 1.3.1
|
44
44
|
requirements: []
|
45
45
|
rubyforge_project:
|
46
|
-
rubygems_version: 2.0.
|
46
|
+
rubygems_version: 2.0.14
|
47
47
|
signing_key:
|
48
48
|
specification_version: 4
|
49
49
|
summary: PredictionIO Ruby SDK
|