recommendation 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Gemfile +16 -0
- data/README.md +61 -0
- data/Rakefile +45 -0
- data/VERSION +1 -0
- data/demo.rb +85 -0
- data/doc/AUTHORS +1 -0
- data/doc/COPYING +674 -0
- data/doc/COPYING.LESSER +165 -0
- data/doc/ChangeLog +5 -0
- data/doc/LICENSE +8 -0
- data/doc/README +16 -0
- data/lib/recommendation.rb +8 -0
- data/lib/recommendation/engine.rb +87 -0
- data/lib/recommendation/supervisor.rb +29 -0
- data/recommendation.gemspec +66 -0
- data/script/build +32 -0
- data/spec/lib/recommendation/engine_spec.rb +204 -0
- data/spec/lib/recommendation/supervisor_spec.rb +101 -0
- data/spec/lib/recommendation_spec.rb +13 -0
- data/spec/spec_helper.rb +26 -0
- data/vendor/.gitkeep +0 -0
- metadata +107 -0
@@ -0,0 +1,101 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
|
4
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
5
|
+
|
6
|
+
describe 'Recommendation::Supervisor' do
|
7
|
+
describe 'initialize and table' do
|
8
|
+
it 'should have empty hash' do
|
9
|
+
supervisor = Recommendation::Supervisor.new
|
10
|
+
supervisor.table.length.should be_eql 0
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe 'initialize and table with args' do
|
15
|
+
it 'should have hash of args' do
|
16
|
+
supervisor = Recommendation::Supervisor.new(initial_data)
|
17
|
+
supervisor.table.should be_eql initial_data
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe 'train' do
|
22
|
+
it 'should merge additional data' do
|
23
|
+
supervisor = Recommendation::Supervisor.new(initial_data)
|
24
|
+
supervisor.train(append_data)
|
25
|
+
supervisor.table.should be_eql merged_data
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe 'integration with engine' do
|
30
|
+
it 'should be suggesting successful' do
|
31
|
+
supervisor = Recommendation::Supervisor.new(merged_data)
|
32
|
+
engine = Recommendation::Engine.new
|
33
|
+
|
34
|
+
expected = {"item_6" => 220.0}
|
35
|
+
result = engine.recommendation(supervisor.table, 'user_4')
|
36
|
+
result.should be_eql expected
|
37
|
+
|
38
|
+
expected = {"user_2"=>1.0, "user_1"=>1.0, "user_3"=>0}
|
39
|
+
result = engine.top_matches(supervisor.table, 'user_4')
|
40
|
+
result.should be_eql expected
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def initial_data
|
46
|
+
{
|
47
|
+
"user_1" => {
|
48
|
+
"item_1" => 100,
|
49
|
+
"item_2" => 140,
|
50
|
+
"item_3" => 160
|
51
|
+
},
|
52
|
+
"user_2" => {
|
53
|
+
"item_2" => 200,
|
54
|
+
"item_4" => 210,
|
55
|
+
"item_6" => 220
|
56
|
+
},
|
57
|
+
"user_3" => {
|
58
|
+
"item_3" => 300,
|
59
|
+
"item_6" => 330,
|
60
|
+
"item_9" => 360
|
61
|
+
}
|
62
|
+
}
|
63
|
+
end
|
64
|
+
|
65
|
+
def append_data
|
66
|
+
{
|
67
|
+
"user_1" => {
|
68
|
+
"item_2" => 400,
|
69
|
+
"item_7" => 410,
|
70
|
+
},
|
71
|
+
"user_4" => {
|
72
|
+
"item_2" => 150,
|
73
|
+
"item_4" => 230,
|
74
|
+
"item_7" => 580
|
75
|
+
}
|
76
|
+
}
|
77
|
+
end
|
78
|
+
|
79
|
+
def merged_data
|
80
|
+
{
|
81
|
+
"user_1" => {
|
82
|
+
"item_2" => 400,
|
83
|
+
"item_7" => 410
|
84
|
+
},
|
85
|
+
"user_2" => {
|
86
|
+
"item_2" => 200,
|
87
|
+
"item_4" => 210,
|
88
|
+
"item_6" => 220
|
89
|
+
},
|
90
|
+
"user_3" => {
|
91
|
+
"item_3" => 300,
|
92
|
+
"item_6" => 330,
|
93
|
+
"item_9" => 360
|
94
|
+
},
|
95
|
+
"user_4" => {
|
96
|
+
"item_2" => 150,
|
97
|
+
"item_4" => 230,
|
98
|
+
"item_7" => 580
|
99
|
+
}
|
100
|
+
}
|
101
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
4
|
+
|
5
|
+
describe Recommendation do
|
6
|
+
context 'const get :VERSION should' do
|
7
|
+
it "return right version number" do
|
8
|
+
expect = '0.1.3'
|
9
|
+
Recommendation.const_get(:VERSION).should be_true
|
10
|
+
Recommendation.const_get(:VERSION).should == expect
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), ".."))
|
4
|
+
$LOAD_PATH.unshift APP_ROOT
|
5
|
+
$LOAD_PATH.unshift File.join(APP_ROOT)
|
6
|
+
$LOAD_PATH.unshift File.join(APP_ROOT, 'lib')
|
7
|
+
|
8
|
+
require 'recommendation'
|
9
|
+
|
10
|
+
if ENV['COVERAGE'] == 'on'
|
11
|
+
require 'simplecov'
|
12
|
+
require 'simplecov-rcov'
|
13
|
+
SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
|
14
|
+
|
15
|
+
SimpleCov.start do
|
16
|
+
add_filter "spec"
|
17
|
+
add_filter "vendor"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
unless /^1\.9\./ =~ RUBY_VERSION
|
22
|
+
require 'rspec'
|
23
|
+
end
|
24
|
+
|
25
|
+
RSpec.configure do |config|
|
26
|
+
end
|
data/vendor/.gitkeep
ADDED
File without changes
|
metadata
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: recommendation
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- id774
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-10-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: cucumber
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: jeweler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Collaborative filtering for recommender system
|
56
|
+
email: idnanashi@gmail.com
|
57
|
+
executables: []
|
58
|
+
extensions: []
|
59
|
+
extra_rdoc_files:
|
60
|
+
- README.md
|
61
|
+
files:
|
62
|
+
- Gemfile
|
63
|
+
- README.md
|
64
|
+
- Rakefile
|
65
|
+
- VERSION
|
66
|
+
- demo.rb
|
67
|
+
- doc/AUTHORS
|
68
|
+
- doc/COPYING
|
69
|
+
- doc/COPYING.LESSER
|
70
|
+
- doc/ChangeLog
|
71
|
+
- doc/LICENSE
|
72
|
+
- doc/README
|
73
|
+
- lib/recommendation.rb
|
74
|
+
- lib/recommendation/engine.rb
|
75
|
+
- lib/recommendation/supervisor.rb
|
76
|
+
- recommendation.gemspec
|
77
|
+
- script/build
|
78
|
+
- spec/lib/recommendation/engine_spec.rb
|
79
|
+
- spec/lib/recommendation/supervisor_spec.rb
|
80
|
+
- spec/lib/recommendation_spec.rb
|
81
|
+
- spec/spec_helper.rb
|
82
|
+
- vendor/.gitkeep
|
83
|
+
homepage: http://github.com/id774/recommendation
|
84
|
+
licenses:
|
85
|
+
- GPL
|
86
|
+
metadata: {}
|
87
|
+
post_install_message:
|
88
|
+
rdoc_options: []
|
89
|
+
require_paths:
|
90
|
+
- lib
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - '>='
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - '>='
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
requirements: []
|
102
|
+
rubyforge_project:
|
103
|
+
rubygems_version: 2.1.5
|
104
|
+
signing_key:
|
105
|
+
specification_version: 4
|
106
|
+
summary: recommendation
|
107
|
+
test_files: []
|