Class: Hiccup::Inferable::Score

Inherits:
Struct
  • Object
show all
Defined in:
lib/hiccup/inferable/score.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#brick_rateObject

Returns the value of attribute brick_rate

Returns:

  • (Object)

    the current value of brick_rate



4
5
6
# File 'lib/hiccup/inferable/score.rb', line 4

def brick_rate
  @brick_rate
end

#complexity_rateObject

Returns the value of attribute complexity_rate

Returns:

  • (Object)

    the current value of complexity_rate



4
5
6
# File 'lib/hiccup/inferable/score.rb', line 4

def complexity_rate
  @complexity_rate
end

#prediction_rateObject

Returns the value of attribute prediction_rate

Returns:

  • (Object)

    the current value of prediction_rate



4
5
6
# File 'lib/hiccup/inferable/score.rb', line 4

def prediction_rate
  @prediction_rate
end

Instance Method Details

#brick_penaltyObject

as brick rate rises, our confidence in this guess drops



7
8
9
10
11
# File 'lib/hiccup/inferable/score.rb', line 7

def brick_penalty
  brick_penalty = brick_rate * 0.33
  brick_penalty = 1 if brick_penalty > 1
  brick_penalty
end

#complexity_penaltyObject

as the complexity rises, our confidence in this guess drops this hash table is a stand-in for a proper formala

A complexity of 1 means that 1 rule is required per input date. This means we haven’t really discovered a pattern.



18
19
20
# File 'lib/hiccup/inferable/score.rb', line 18

def complexity_penalty
  complexity_rate
end

#confidenceObject

our confidence is weakened by bricks and complexity



23
24
25
26
27
28
# File 'lib/hiccup/inferable/score.rb', line 23

def confidence
  confidence = 1.0
  confidence *= (1 - brick_penalty)
  confidence *= (1 - complexity_penalty)
  confidence
end

#to_fObject

a number between 0 and 1



31
32
33
# File 'lib/hiccup/inferable/score.rb', line 31

def to_f
  prediction_rate * confidence
end