predictable 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NjNkNTE5YTc1NjA5MDEyNjc4YTk1NDViMThmYjBiZjY5ZDkzNTQ3Ng==
4
+ ODY2N2ViZWRjMTY0Mjk1ZDliOWM1Y2ViY2NiYTlkZTQxYWU3N2VhNg==
5
5
  data.tar.gz: !binary |-
6
- MmY0YmRmMjgxZDhhMjU1OTBjMjhkYmMwMjc2YjM3YmMyYjA3MGQ2NA==
6
+ OWExYmEwZmQwZTEzOTA5ODY3NDkwYmVjZmZlYjFkOGNmYTMyYjU4Yw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NWI0NGUzYjkyZThjMzY5ZWEwODA1YmIzMTg3ZjQ4NDUzZGM1OWExOWRmNzVm
10
- NzhlOTJjNWYxMjAxMWU1MTk2NzY2YmQ2NzExMDM1OWIyYjFiYTExYzcwMWYz
11
- M2RjODllNDRjMjBkZGNmZDFmODlmMzdhYzQxY2I0OTJiMmYyNDc=
9
+ MmFjODEzMmVmOWU4NmU4MzgzNzIwNzYzN2EwYzU4OTk3NmIwNjBjMTMyNzBk
10
+ Y2EzODc0MGQ3N2EyZWRlZWNiOTBlNzFjNGU0ZTA5ZTMyMzBlMDYyOGVmZTY3
11
+ Nzg4ZTQ2NzMzZWRkZDVmOWYxN2E4ZWM5MmIwMDZlYmJmYTg2YTc=
12
12
  data.tar.gz: !binary |-
13
- YjBkZjExNGRhYzU2NjU3NjUxYTMzMmY4NzYzYzAyNDE1MzY4OGYxYjlhMjM2
14
- MzY3MDViYTkyYWMyMzJmYzZkZTI0NTc4MDBmMTJiMTEzYzRjYmExYzRmOTgw
15
- NTk3NGU5MWEyMjY3MjY1YmNmZjJjODY2NDU1ZTJmMzA2OWE4ZDY=
13
+ NzA1NzBiNjM5N2E4N2QzNzhhMjdiNDczYzEyNGU3ZjA4MzMzOTgwMGZjYTdj
14
+ YzJjMmUwYmM2YTRkNThhZDIxZjg1YzRmZDc2MjczNmU2YWZkMGVkNmVlYmM4
15
+ YTNiZjY3ZWI4ZGM3NmJjOGY1ZDk4YjQ2OTJlYTBlNGFkOTMwMTA=
data/README.md CHANGED
@@ -26,31 +26,22 @@ Include Predictable::User in your application's User model.
26
26
  ...
27
27
  end
28
28
 
29
- user = User.create(email: "js@perkhub.com")
30
- user.add_to_recommender
31
-
32
29
  Include the Predictable::Item in the models of the items you want to recommend.
33
30
 
34
31
  class Offer < ActiveRecord::Base
35
32
  include Predictable::Item
36
33
 
37
- after_create { add_to_recommender }
38
- after_destroy { delete_from_recommender }
39
-
40
34
  ...
41
35
  end
42
36
 
43
37
  Get 10 recommended items for a user.
44
38
 
45
- Offer.recommended_for(user)
46
- current_user.recommended_offers.where("created_at > ?", 1.week.ago).limit(10)
39
+ Offer.recommended_for(user, 10)
47
40
 
48
41
  Get 10 items most similar to an existing item.
49
42
 
50
- Offer.similar_to(offer)
51
-
43
+ Offer.similar_to(offer, 10)
52
44
 
53
- current_user.recommended_offers.limit(10)
54
45
 
55
46
  ## Contributing
56
47
 
@@ -21,12 +21,6 @@ module Predictable
21
21
  module Item
22
22
  extend ActiveSupport::Concern
23
23
 
24
- included do
25
- # if active_record? defined?(ActiveRecord::Base) && ancestors.include?(ActiveRecord::Base)
26
- after_create { add_to_recommender }
27
- after_destroy { delete_from_recommender }
28
- end
29
-
30
24
  # Returns the item id
31
25
  def pio_iid
32
26
  "#{self.class.pio_itype}-#{id}"
@@ -73,21 +67,20 @@ module Predictable
73
67
  to_s.underscore
74
68
  end
75
69
 
76
- def recommended_for(user, opts = {})
70
+ def recommended_for(user, n, opts={})
77
71
  options = { "itypes" => [pio_itype] }.merge(opts)
78
- limit = options.delete("limit") || 10
79
72
 
80
- item_ids = recommender.recommended_items(user, limit, options)
73
+ item_ids = recommender.recommended_items(user, n, options)
81
74
  item_ids = item_ids.map { |id| id.gsub! /[^\d]/, '' }
82
75
  where(:id => item_ids)
83
76
  end
84
77
 
85
- def similar_to(item, opts={})
78
+ def similar_to(item, n, opts={})
86
79
  options = opts.stringify_keys
87
80
  options["pio_itypes"] ||= [pio_itype]
88
- limit = options.delete("limit") || 10
81
+ limit = options.delete("limit") || 100
89
82
 
90
- item_ids = recommender.similar_items(item, limit, options)
83
+ item_ids = recommender.similar_items(item, n, options)
91
84
  item_ids = item_ids.map { |id| id.gsub! /[^\d]/, '' }
92
85
  where(:id => item_ids)
93
86
  end
@@ -14,12 +14,6 @@ module Predictable
14
14
  module User
15
15
  extend ActiveSupport::Concern
16
16
 
17
- included do
18
- # if active_record? defined?(ActiveRecord::Base) && ancestors.include?(ActiveRecord::Base)
19
- after_create { add_to_recommender }
20
- after_destroy { delete_from_recommender }
21
- end
22
-
23
17
  # Returns the user id
24
18
  def pio_uid
25
19
  self.id
@@ -1,3 +1,3 @@
1
1
  module Predictable
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
8
8
  spec.version = Predictable::VERSION
9
9
  spec.authors = ["JS Boulanger"]
10
10
  spec.email = ["jsboulanger@gmail.com"]
11
- spec.description = "Ruby/Rails DSL for PredictionIO, an open source machine learning server."
12
- spec.summary = "Ruby/Rails DSL for PredictionIO"
11
+ spec.description = "Ruby/Rails DSL for Prediction.io, an open source machine learning server."
12
+ spec.summary = "Ruby/Rails DSL for Prediction.io."
13
13
  spec.homepage = "https://github.com/jsboulanger/predictable"
14
14
  spec.license = "MIT"
15
15
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: predictable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - JS Boulanger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-06 00:00:00.000000000 Z
11
+ date: 2014-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -80,7 +80,7 @@ dependencies:
80
80
  - - ! '>='
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
- description: Ruby/Rails DSL for PredictionIO, an open source machine learning server.
83
+ description: Ruby/Rails DSL for Prediction.io, an open source machine learning server.
84
84
  email:
85
85
  - jsboulanger@gmail.com
86
86
  executables: []
@@ -126,7 +126,7 @@ rubyforge_project:
126
126
  rubygems_version: 2.1.11
127
127
  signing_key:
128
128
  specification_version: 4
129
- summary: Ruby/Rails DSL for PredictionIO
129
+ summary: Ruby/Rails DSL for Prediction.io.
130
130
  test_files:
131
131
  - spec/predictable/item_spec.rb
132
132
  - spec/predictable/recommender_spec.rb