Home Reference Source Test
import {ThompsonSampling} from 'modelscript/src/ReinforcedLearning.mjs'
public class | source

ThompsonSampling

Extends:

ReinforcedLearningBase → ThompsonSampling

Implementation of the Thompson Sampling algorithm

Constructor Summary

Public Constructor
public

constructor(options: Object): this

creates a new instance of the Thompson Sampling(TS) algorithm.

Member Summary

Public Members
public
public
public

Method Summary

Public Methods
public

learn(tsRow: Object, getBound: Function): this

single step trainning method

public

predict(): number

returns next action based off of the thompson sampling

public

train(tsRow: Object | Object[], getBound: Function): this

training method for thompson sampling calculations

Inherited Summary

From class ReinforcedLearningBase
public
public
public
public
public
public

learn()

interface instance method for reinforced learning step

public

interface instance method for reinforced prediction step

public

train()

interface instance method for reinforced training step

Public Constructors

public constructor(options: Object): this source

creates a new instance of the Thompson Sampling(TS) algorithm. TS a heuristic for choosing actions that addresses the exploration-exploitation dilemma in the multi-armed bandit problem. It consists in choosing the action that maximizes the expected reward with respect to a randomly drawn belief

Override:

ReinforcedLearningBase#constructor

Params:

NameTypeAttributeDescription
options Object
  • optional
  • default: {}

Return:

this

Example:

const dataset = new ms.ml.ThompsonSampling({bounds:10});

See:

  • https://en.wikipedia.org/wiki/Thompson_sampling

Public Members

public numbers_of_rewards_0 source

public numbers_of_rewards_1 source

public total_reward source

Override:

ReinforcedLearningBase#total_reward

Public Methods

public learn(tsRow: Object, getBound: Function): this source

single step trainning method

Override:

ReinforcedLearningBase#learn

Params:

NameTypeAttributeDescription
tsRow Object

row of bound selections

getBound Function
  • optional
  • default: this.getBound

select value of tsRow by selection value

Return:

this

public predict(): number source

returns next action based off of the thompson sampling

Override:

ReinforcedLearningBase#predict

Return:

number

returns thompson sample

public train(tsRow: Object | Object[], getBound: Function): this source

training method for thompson sampling calculations

Override:

ReinforcedLearningBase#train

Params:

NameTypeAttributeDescription
tsRow Object | Object[]

row of bound selections

getBound Function
  • optional
  • default: this.getBound

select value of tsRow by selection value

Return:

this