predictionio 0.8.3 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cc76e93ff1fab8a8b64c20b829a9e69cfd7012ce
4
- data.tar.gz: 5beeca9b2a0c237bacaa31459cae35c91984dcdb
3
+ metadata.gz: da7586b887055412f1f000be93ad5bd565a36be5
4
+ data.tar.gz: 3ed3df0f0daa02fe345cd65ab2dd91c1d4ec52d9
5
5
  SHA512:
6
- metadata.gz: a8658f74d556d39a6784c5d8b5e17adec7bcf572122929ec042a92f8a7311cb0498cd020a3db19f3a753321eead44e72aed5b78ac30f82e0476e9d3e8a14f438
7
- data.tar.gz: c3ece6c9ce8303abf3247a7e879792ebb68720409630b045af82bddb0cc6afba3d56e48e3d950707b8949871237cbfc9b7631a19570c1a4a0ef635268f7820bf
6
+ metadata.gz: 8867009b24ce3fb765799f70c58268b19fe8b30a89afe783d6d923ca48fff4612732119d6472618de1ca52c2399a27256cca559f610c3f26a8753dfd83817baa
7
+ data.tar.gz: 8268c54337b6233a4e9e0584f5a85dedcccb2a6aa162bff1fed0939412b4d59038e3b54d12e649b5458ae05b96a4a18b0afbd3c97b4ca24a51894e11549c0785
@@ -4,10 +4,6 @@
4
4
  # Copyright:: Copyright (c) 2014 TappingStone, Inc.
5
5
  # License:: Apache License, Version 2.0
6
6
 
7
- require 'predictionio/async_request'
8
- require 'predictionio/async_response'
9
- require 'predictionio/connection'
10
-
11
7
  module PredictionIO
12
8
  # This class contains methods that interface with PredictionIO Engine
13
9
  # Instances that are trained from PredictionIO built-in Engines.
@@ -70,6 +66,30 @@ module PredictionIO
70
66
  end
71
67
  end
72
68
 
69
+ # :category: Asynchronous Methods
70
+ # Asynchronously sends a query and returns PredictionIO::AsyncResponse
71
+ # object immediately. The query should be a Ruby data structure that can be
72
+ # converted to a JSON object.
73
+ #
74
+ # Corresponding REST API method: POST /
75
+ #
76
+ # See also #send_query.
77
+ def asend_query(query)
78
+ @http.apost(PredictionIO::AsyncRequest.new('/queries.json', query.to_json))
79
+ end
80
+
81
+ # :category: Synchronous Methods
82
+ # Synchronously sends a query and block until predictions are received.
83
+ #
84
+ # See also #asend_query.
85
+ #
86
+ # call-seq:
87
+ # send_query(data)
88
+ # send_query(async_response)
89
+ def send_query(*args)
90
+ sync_events(:asend_query, *args)
91
+ end
92
+
73
93
  protected
74
94
 
75
95
  # Internal helper method. Do not call directly.
@@ -95,31 +115,5 @@ module PredictionIO
95
115
  fail msg
96
116
  end
97
117
  end
98
-
99
- public
100
-
101
- # :category: Asynchronous Methods
102
- # Asynchronously sends a query and returns PredictionIO::AsyncResponse
103
- # object immediately. The query should be a Ruby data structure that can be
104
- # converted to a JSON object.
105
- #
106
- # Corresponding REST API method: POST /
107
- #
108
- # See also #send_query.
109
- def asend_query(query)
110
- @http.apost(PredictionIO::AsyncRequest.new('/queries.json', query.to_json))
111
- end
112
-
113
- # :category: Synchronous Methods
114
- # Synchronously sends a query and block until predictions are received.
115
- #
116
- # See also #asend_query.
117
- #
118
- # call-seq:
119
- # send_query(data)
120
- # send_query(async_response)
121
- def send_query(*args)
122
- sync_events(:asend_query, *args)
123
- end
124
118
  end
125
119
  end
@@ -4,9 +4,6 @@
4
4
  # Copyright:: Copyright (c) 2014 TappingStone, Inc.
5
5
  # License:: Apache License, Version 2.0
6
6
 
7
- require 'predictionio/async_request'
8
- require 'predictionio/async_response'
9
- require 'predictionio/connection'
10
7
  require 'date'
11
8
 
12
9
  module PredictionIO
@@ -104,26 +101,6 @@ module PredictionIO
104
101
  end
105
102
  end
106
103
 
107
- protected
108
-
109
- # Internal helper method. Do not call directly.
110
- def sync_events(sync_m, *args)
111
- if args[0].is_a?(PredictionIO::AsyncResponse)
112
- response = args[0].get
113
- else
114
- response = send(sync_m, *args).get
115
- end
116
- return response if response.is_a?(Net::HTTPCreated)
117
- begin
118
- msg = response.body
119
- rescue
120
- raise NotCreatedError, response
121
- end
122
- fail NotCreatedError, msg
123
- end
124
-
125
- public
126
-
127
104
  # :category: Asynchronous Methods
128
105
  # Asynchronously request to create an event and return a
129
106
  # PredictionIO::AsyncResponse object immediately.
@@ -336,5 +313,23 @@ module PredictionIO
336
313
  def record_user_action_on_item(*args)
337
314
  sync_events(:arecord_user_action_on_item, *args)
338
315
  end
316
+
317
+ protected
318
+
319
+ # Internal helper method. Do not call directly.
320
+ def sync_events(sync_m, *args)
321
+ if args[0].is_a?(PredictionIO::AsyncResponse)
322
+ response = args[0].get
323
+ else
324
+ response = send(sync_m, *args).get
325
+ end
326
+ return response if response.is_a?(Net::HTTPCreated)
327
+ begin
328
+ msg = response.body
329
+ rescue
330
+ raise NotCreatedError, response
331
+ end
332
+ fail NotCreatedError, msg
333
+ end
339
334
  end
340
335
  end
@@ -0,0 +1,29 @@
1
+ module PredictionIO
2
+ # This class contains methods that allow you to export data for import though:
3
+ #
4
+ # $ pio import FILENAME
5
+
6
+ class FileExporter
7
+
8
+ def initialize(filename)
9
+ @filename = filename
10
+ @file = File.open(@filename, 'w')
11
+ end
12
+
13
+ def create_event(event, entity_type, entity_id, optional = {})
14
+
15
+ h = optional
16
+ h.key?('eventTime') || h['eventTime'] = DateTime.now.to_s
17
+ h['event'] = event
18
+ h['entityType'] = entity_type
19
+ h['entityId'] = entity_id
20
+
21
+ json = h.to_json
22
+ @file.write("#{json}\n")
23
+ end
24
+
25
+ def close
26
+ @file.close
27
+ end
28
+ end
29
+ end
@@ -1,3 +1,3 @@
1
1
  module PredictionIO
2
- VERSION = '0.8.3'
3
- end
2
+ VERSION = '0.9.0'
3
+ end
data/lib/predictionio.rb CHANGED
@@ -1,5 +1,11 @@
1
+ require 'json'
2
+ require 'predictionio/async_request'
3
+ require 'predictionio/async_response'
4
+ require 'predictionio/connection'
1
5
  require 'predictionio/event_client'
2
6
  require 'predictionio/engine_client'
7
+ require 'predictionio/file_exporter'
8
+ require 'predictionio/version'
3
9
 
4
10
  # The PredictionIO module contains classes that provide convenient access of
5
11
  # PredictionIO Event API and Engine Instance over HTTP/HTTPS.
metadata CHANGED
@@ -1,19 +1,34 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: predictionio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.3
4
+ version: 0.9.0
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-12-10 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2015-03-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: json
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.8'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.8'
13
27
  description: |
14
- PredictionIO is a prediction server for building smart applications. This gem
15
- provides convenient access of the PredictionIO API to Ruby programmers so that
16
- they can focus on application logic.
28
+ PredictionIO is an open source machine learning server for developers and data
29
+ scientists to create predictive engines for production environments. This gem
30
+ provides convenient access to the PredictionIO API for Ruby programmers so that
31
+ you can focus on application logic.
17
32
  email: support@prediction.io
18
33
  executables: []
19
34
  extensions: []
@@ -25,8 +40,9 @@ files:
25
40
  - lib/predictionio/connection.rb
26
41
  - lib/predictionio/engine_client.rb
27
42
  - lib/predictionio/event_client.rb
43
+ - lib/predictionio/file_exporter.rb
28
44
  - lib/predictionio/version.rb
29
- homepage: http://prediction.io
45
+ homepage: http://prediction.io/
30
46
  licenses:
31
47
  - Apache-2.0
32
48
  metadata: {}
@@ -38,7 +54,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
38
54
  requirements:
39
55
  - - '>='
40
56
  - !ruby/object:Gem::Version
41
- version: '1.9'
57
+ version: 1.9.3
42
58
  required_rubygems_version: !ruby/object:Gem::Requirement
43
59
  requirements:
44
60
  - - '>='