Sha256: 1daf8c1cba1f03621cb73e0f0856bbfdb6d431de73276f711319d3d5b2207c97

Contents?: true

Size: 993 Bytes

Versions: 8

Compression:

Stored size: 993 Bytes

Contents

module Hiccup
  module Inferable

    class Score < Struct.new(:prediction_rate, :brick_rate, :complexity_rate)

      # as brick rate rises, our confidence in this guess drops
      def brick_penalty
        brick_penalty = brick_rate * 0.33
        brick_penalty = 1 if brick_penalty > 1
        brick_penalty
      end

      # 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.
      def complexity_penalty
        complexity_rate
      end

      # our confidence is weakened by bricks and complexity
      def confidence
        confidence = 1.0
        confidence *= (1 - brick_penalty)
        confidence *= (1 - complexity_penalty)
        confidence
      end

      # a number between 0 and 1
      def to_f
        prediction_rate * confidence
      end

    end

  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
hiccup-0.6.1 lib/hiccup/inferable/score.rb
hiccup-0.6.0 lib/hiccup/inferable/score.rb
hiccup-0.5.20 lib/hiccup/inferable/score.rb
hiccup-0.5.19 lib/hiccup/inferable/score.rb
hiccup-0.5.18 lib/hiccup/inferable/score.rb
hiccup-0.5.17 lib/hiccup/inferable/score.rb
hiccup-0.5.16 lib/hiccup/inferable/score.rb
hiccup-0.5.15 lib/hiccup/inferable/score.rb