Sha256: 13dfcc96f4571dafd8956b26e2051ec3be08a8a60e67f05e8e8dd56968c8b04c

Contents?: true

Size: 817 Bytes

Versions: 4

Compression:

Stored size: 817 Bytes

Contents

module EasyML
  module Models
    module Hyperparameters
      class Base
        include GlueGun::DSL

        attribute :learning_rate, :float, default: 0.01
        attribute :max_iterations, :integer, default: 100
        attribute :batch_size, :integer, default: 32
        attribute :regularization, :float, default: 0.0001

        def to_h
          attributes
        end

        def merge(other)
          return self if other.nil?

          other_hash = other.is_a?(Hyperparameters) ? other.to_h : other
          merged_hash = to_h.merge(other_hash)
          self.class.new(**merged_hash)
        end

        def [](key)
          send(key) if respond_to?(key)
        end

        def []=(key, value)
          send("#{key}=", value) if respond_to?("#{key}=")
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
easy_ml-0.1.4 lib/easy_ml/core/models/hyperparameters/base.rb
easy_ml-0.1.3 lib/easy_ml/core/models/hyperparameters/base.rb
easy_ml-0.1.2 lib/easy_ml/core/models/hyperparameters/base.rb
easy_ml-0.1.1 lib/easy_ml/core/models/hyperparameters/base.rb