Sha256: a6527bcf4620577aa8c814919efd9abf9078aadd8f4253f24c49a750c977a668

Contents?: true

Size: 1.08 KB

Versions: 46

Compression:

Stored size: 1.08 KB

Contents

module EasyML
  module Core
    module Evaluators
      module BaseEvaluator
        def self.included(base)
          base.extend(ClassMethods)
        end

        def direction
          "minimize"
        end

        def label
          key.split("_").join(" ").titleize
        end

        def to_option
          EasyML::Option.new(to_h)
        end

        def to_h
          {
            value: key,
            label: label,
            direction: direction
          }
        end

        def key
          self.class.name.split("::").last.underscore
        end

        # Instance methods that evaluators must implement
        def evaluate(y_pred: nil, y_true: nil, x_true: nil)
          raise NotImplementedError, "#{self.class} must implement #evaluate"
        end

        def calculate_result(metrics)
          metrics.symbolize_keys!
          metrics[metric.to_sym]
        end

        module ClassMethods
          def self.extended(base)
            class << base
              attr_accessor :registry
            end
          end
        end
      end
    end
  end
end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
easy_ml-0.2.0.pre.rc47 lib/easy_ml/core/evaluators/base_evaluator.rb
easy_ml-0.2.0.pre.rc46 lib/easy_ml/core/evaluators/base_evaluator.rb
easy_ml-0.2.0.pre.rc45 lib/easy_ml/core/evaluators/base_evaluator.rb
easy_ml-0.2.0.pre.rc44 lib/easy_ml/core/evaluators/base_evaluator.rb
easy_ml-0.2.0.pre.rc43 lib/easy_ml/core/evaluators/base_evaluator.rb
easy_ml-0.2.0.pre.rc41 lib/easy_ml/core/evaluators/base_evaluator.rb
easy_ml-0.2.0.pre.rc40 lib/easy_ml/core/evaluators/base_evaluator.rb
easy_ml-0.2.0.pre.rc39 lib/easy_ml/core/evaluators/base_evaluator.rb
easy_ml-0.2.0.pre.rc38 lib/easy_ml/core/evaluators/base_evaluator.rb
easy_ml-0.2.0.pre.rc37 lib/easy_ml/core/evaluators/base_evaluator.rb
easy_ml-0.2.0.pre.rc36 lib/easy_ml/core/evaluators/base_evaluator.rb
easy_ml-0.2.0.pre.rc35 lib/easy_ml/core/evaluators/base_evaluator.rb
easy_ml-0.2.0.pre.rc34 lib/easy_ml/core/evaluators/base_evaluator.rb
easy_ml-0.2.0.pre.rc33 lib/easy_ml/core/evaluators/base_evaluator.rb
easy_ml-0.2.0.pre.rc32 lib/easy_ml/core/evaluators/base_evaluator.rb
easy_ml-0.2.0.pre.rc31 lib/easy_ml/core/evaluators/base_evaluator.rb
easy_ml-0.2.0.pre.rc30 lib/easy_ml/core/evaluators/base_evaluator.rb
easy_ml-0.2.0.pre.rc29 lib/easy_ml/core/evaluators/base_evaluator.rb
easy_ml-0.2.0.pre.rc28 lib/easy_ml/core/evaluators/base_evaluator.rb
easy_ml-0.2.0.pre.rc27 lib/easy_ml/core/evaluators/base_evaluator.rb