Class: CollaborativeFilter::DataSet
- Inherits:
-
Object
- Object
- CollaborativeFilter::DataSet
- Defined in:
- lib/collaborative_filter/data_set.rb
Defined Under Namespace
Classes: Error
Instance Attribute Summary collapse
-
#items(input = nil) ⇒ Object
Returns the value of attribute items.
-
#m ⇒ Object
Returns the value of attribute m.
-
#similarities ⇒ Object
Returns the value of attribute similarities.
-
#users(input = nil) ⇒ Object
Returns the value of attribute users.
Instance Method Summary collapse
- #correlator(input = nil) ⇒ Object
- #item_index(id, type = nil) ⇒ Object
- #nodes(input = nil) ⇒ Object
- #options(opts = nil) ⇒ Object
- #run ⇒ Object
- #user_index(id, type = nil) ⇒ Object
Instance Attribute Details
#items(input = nil) ⇒ Object
Returns the value of attribute items.
4 5 6 |
# File 'lib/collaborative_filter/data_set.rb', line 4 def items @items end |
#m ⇒ Object
Returns the value of attribute m.
5 6 7 |
# File 'lib/collaborative_filter/data_set.rb', line 5 def m @m end |
#similarities ⇒ Object
Returns the value of attribute similarities.
6 7 8 |
# File 'lib/collaborative_filter/data_set.rb', line 6 def similarities @similarities end |
#users(input = nil) ⇒ Object
Returns the value of attribute users.
3 4 5 |
# File 'lib/collaborative_filter/data_set.rb', line 3 def users @users end |
Instance Method Details
#correlator(input = nil) ⇒ Object
48 49 50 51 |
# File 'lib/collaborative_filter/data_set.rb', line 48 def correlator(input=nil) return @correlator unless input @correlator = input end |
#item_index(id, type = nil) ⇒ Object
55 56 57 |
# File 'lib/collaborative_filter/data_set.rb', line 55 def item_index(id,type=nil) find_index(id,type,@items) end |
#nodes(input = nil) ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/collaborative_filter/data_set.rb', line 34 def nodes(input=nil) if block_given? @m = GSL::Matrix[@items.size,@users.size] yield @m else @m = input.is_a?(GSL::Matrix) ? input : GSL::Matrix[*input] end end |
#options(opts = nil) ⇒ Object
43 44 45 46 |
# File 'lib/collaborative_filter/data_set.rb', line 43 def (opts=nil) return @options unless opts @options = opts end |
#run ⇒ Object
63 64 65 |
# File 'lib/collaborative_filter/data_set.rb', line 63 def run @similarities = @correlator.new.run(@m, @users, @items, @options) end |
#user_index(id, type = nil) ⇒ Object
59 60 61 |
# File 'lib/collaborative_filter/data_set.rb', line 59 def user_index(id,type=nil) find_index(id,type,@users) end |