Class: ComplexityAssert::Matchers

Inherits:
Object
  • Object
show all
Defined in:
lib/complexity_assert/matchers.rb

Class Method Summary collapse

Class Method Details

.best_complexity_by_rmse(complexity_errors) ⇒ Object

complexity_errors : [[“big O notation”, rmse score], …], in order of complexity costs



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/complexity_assert/matchers.rb', line 7

def self.best_complexity_by_rmse(complexity_errors)
  best = complexity_errors.first
  complexity_errors.drop(1).each do |comp_error|

    # we favor simpler complexities to fight overfitting from more elaborate models
    if comp_error[1] < best[1] / 2
      best = comp_error
    end
  end
  best[0]
end