Class: SkiftetStatistical::Policies::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/skiftet_statistical/policies/base.rb

Overview

A selection policy decides which arm to pull next from the current stats. Subclasses implement #choose(arms), returning the chosen Arm.

Direct Known Subclasses

EpsilonGreedy, Softmax, ThompsonSampling, UCB1

Instance Method Summary collapse

Instance Method Details

#choose(_arms) ⇒ Object

Pick an arm. arms is a non-empty Array; returns the chosen Arm.

Raises:

  • (NotImplementedError)


9
10
11
# File 'lib/skiftet_statistical/policies/base.rb', line 9

def choose(_arms)
  raise NotImplementedError, "#{self.class} must implement #choose"
end

#to_hObject

Serialisable config (so a Bandit can describe its policy).



14
15
16
# File 'lib/skiftet_statistical/policies/base.rb', line 14

def to_h
  { type: self.class.name.split("::").last }
end