Class: CollaborativeFilter::ContentBooster

Inherits:
Object
  • Object
show all
Defined in:
lib/collaborative_filter/content_booster.rb

Defined Under Namespace

Classes: Gene

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeContentBooster

Returns a new instance of ContentBooster.



6
7
8
# File 'lib/collaborative_filter/content_booster.rb', line 6

def initialize
  @genes = {}
end

Instance Attribute Details

#booster(booster_class = nil) ⇒ Object (readonly)

Returns the value of attribute booster.



4
5
6
# File 'lib/collaborative_filter/content_booster.rb', line 4

def booster
  @booster
end

#genesObject (readonly)

Returns the value of attribute genes.



3
4
5
# File 'lib/collaborative_filter/content_booster.rb', line 3

def genes
  @genes
end

Instance Method Details

#crossover(point = nil) ⇒ Object



21
22
23
24
# File 'lib/collaborative_filter/content_booster.rb', line 21

def crossover(point=nil)
  return @crossover unless point
  @crossover = point
end

#factor(input = nil) ⇒ Object



31
32
33
34
# File 'lib/collaborative_filter/content_booster.rb', line 31

def factor(input=nil)
  return @factor unless input
  @factor = input
end

#gene(name, &block) ⇒ Object



15
16
17
18
19
# File 'lib/collaborative_filter/content_booster.rb', line 15

def gene(name, &block)
  gene = Gene.new
  gene.finder = block
  @genes[name] = gene
end

#run(recommendations, datasets) ⇒ Object



37
38
39
40
# File 'lib/collaborative_filter/content_booster.rb', line 37

def run(recommendations,datasets)
  options = { :crossover => @crossover, :threshold => @threshold, :factor => @factor }
  @booster.new.run(recommendations,datasets,@genes,options)
end

#threshold(input = nil) ⇒ Object



26
27
28
29
# File 'lib/collaborative_filter/content_booster.rb', line 26

def threshold(input=nil)
  return @threshold unless input
  @threshold = input
end