Implementation of the Thompson Sampling algorithm

memberof

  ml

### Hierarchy

- ReinforcedLearningBase
  - ThompsonSampling

### Implements

- ReinforcedLearning

### Indexable

[x: string]: any

Implementation of the Thompson Sampling algorithm

memberof

  ml

## Index

### Constructors

- constructor

### Properties

- bounds
- getBound
- iteration
- last_selected
- total_reward

### Methods

- learn
- predict
- train

## Constructors

### constructor

- new ThompsonSampling(options?: any): ThompsonSampling

- Overrides ReinforcedLearningBase.constructor

  - Defined in ReinforcedLearning.ts:180

  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

  see

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

  example

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

  prop

    {Map} this.numbers_of_rewards_1 - map of all reward 1 selections

  prop

    {Map} this.numbers_of_rewards_0 - map of all reward 0 selections

  #### Parameters

  - ##### Default value options: any = {}

  #### Returns ThompsonSampling

## Properties

### bounds

bounds: number

Implementation of ReinforcedLearning.bounds

Inherited from ReinforcedLearningBase.bounds

- Defined in ReinforcedLearning.ts:26

### getBound

getBound: BoundFunction

Implementation of ReinforcedLearning.getBound

Inherited from ReinforcedLearningBase.getBound

- Defined in ReinforcedLearning.ts:27

### iteration

iteration: number

Implementation of ReinforcedLearning.iteration

Inherited from ReinforcedLearningBase.iteration

- Defined in ReinforcedLearning.ts:30

### last_selected

last_selected: Vector

Implementation of ReinforcedLearning.last_selected

Inherited from ReinforcedLearningBase.last_selected

- Defined in ReinforcedLearning.ts:28

### total_reward

total_reward: number

Implementation of ReinforcedLearning.total_reward

Inherited from ReinforcedLearningBase.total_reward

- Defined in ReinforcedLearning.ts:29

## Methods

### learn

- learn(options?: any): this

- Overrides ReinforcedLearningBase.learn

  - Defined in ReinforcedLearning.ts:224

  single step trainning method

  #### Parameters

  - ##### Default value options: any = {}

  #### Returns this

### predict

- predict(): number

- Overrides ReinforcedLearningBase.predict

  - Defined in ReinforcedLearning.ts:205

  returns next action based off of the thompson sampling

  #### Returns number

  returns thompson sample

### train

- train(options: any): this

- Overrides ReinforcedLearningBase.train

  - Defined in ReinforcedLearning.ts:245

  training method for thompson sampling calculations

  #### Parameters

  - ##### options: any

  #### Returns this