mab

package module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 31, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

README

Multi-Armed Bandit Package

Multi-Armed Bandit Reinforcement Learning algorithms.

Documentation

Overview

Copyright 2020 Humility AI Incorporated, All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2020 Humility AI Incorporated, All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2020 Humility AI Incorporated, All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2020 Humility AI Incorporated, All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2020 Humility AI Incorporated, All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2020 Humility AI Incorporated, All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrIndex   = errors.New("index out of bounds")
	ErrEpsilon = errors.New("invalid epsilon value")
	ErrOptions = errors.New("too few options")
	ErrReward  = errors.New("invalid reward value")
)

Functions

This section is empty.

Types

type AnnealingSoftmax

type AnnealingSoftmax struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

AnnealingSoftmax ...

func (*AnnealingSoftmax) Counts

func (a *AnnealingSoftmax) Counts() sam.SliceInt

Counts returns a copy of the counts slice

func (*AnnealingSoftmax) Extend added in v0.1.0

func (a *AnnealingSoftmax) Extend(n int)

Extend --

func (*AnnealingSoftmax) Remove

func (a *AnnealingSoftmax) Remove(option int)

Remove --

func (*AnnealingSoftmax) Rewards

func (a *AnnealingSoftmax) Rewards() sam.SliceFloat64

Rewards returns a copy of the rewards slice

func (*AnnealingSoftmax) Select

func (a *AnnealingSoftmax) Select() int

Select ...

func (*AnnealingSoftmax) Significant added in v0.1.1

func (a *AnnealingSoftmax) Significant(pvalue float64) bool

Significant --

func (*AnnealingSoftmax) Update

func (a *AnnealingSoftmax) Update(option int, reward float64) error

Update should be used to increment the given option with the given reward amount.

type EpsilonGreedy

type EpsilonGreedy struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

EpsilonGreedy is the simplest, easiest, and most "good-enough" multi-armed bandit optimizer to utilize.

func (*EpsilonGreedy) Counts

func (e *EpsilonGreedy) Counts() sam.SliceInt

Counts returns a copy of the counts slice

func (*EpsilonGreedy) Extend added in v0.1.0

func (e *EpsilonGreedy) Extend(n int)

Extend --

func (*EpsilonGreedy) Remove

func (e *EpsilonGreedy) Remove(option int)

Remove --

func (*EpsilonGreedy) Rewards

func (e *EpsilonGreedy) Rewards() sam.SliceFloat64

Rewards returns a copy of the rewards slice

func (*EpsilonGreedy) Select

func (e *EpsilonGreedy) Select() int

Select will select an option randomly.

func (*EpsilonGreedy) Significant added in v0.1.1

func (e *EpsilonGreedy) Significant(pvalue float64) bool

Significant --

func (*EpsilonGreedy) Update

func (e *EpsilonGreedy) Update(option int, reward float64) error

Update should be used to increment the given option with the given reward amount.

type Optimizer

type Optimizer interface {
	Select() int
	Update(selection int, reward float64) error
	Extend(int)
	Remove(int)
	Significant(float64) bool
	Counts() sam.SliceInt
	Rewards() sam.SliceFloat64
}

Optimizer represents a generic recommendation learning based bandit.

func NewAnnealingSoftmax

func NewAnnealingSoftmax(options int) (Optimizer, error)

NewAnnealingSoftmax ...

func NewEpsilonGreedy

func NewEpsilonGreedy(options int, epsilon float64) (Optimizer, error)

NewEpsilonGreedy will create and return a new EpsilonGreedy mab optimizer. Epsilon value must be between 0 and 1. The number of options must be 2 or greater.

func NewThompsonSampling

func NewThompsonSampling(options int) (Optimizer, error)

NewThompsonSampling ...

func NewUpperConfidenceBound

func NewUpperConfidenceBound(options int) (Optimizer, error)

NewUpperConfidenceBound ...

type ThompsonSampling

type ThompsonSampling struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

ThompsonSampling ...

func (*ThompsonSampling) Counts

func (t *ThompsonSampling) Counts() sam.SliceInt

Counts returns a copy of the counts slice

func (*ThompsonSampling) Extend added in v0.1.0

func (t *ThompsonSampling) Extend(n int)

Extend --

func (*ThompsonSampling) Remove

func (t *ThompsonSampling) Remove(option int)

Remove --

func (*ThompsonSampling) Rewards

func (t *ThompsonSampling) Rewards() sam.SliceFloat64

Rewards returns a copy of the rewards slice

func (*ThompsonSampling) Select

func (t *ThompsonSampling) Select() int

Select ...

func (*ThompsonSampling) Significant added in v0.1.1

func (t *ThompsonSampling) Significant(pvalue float64) bool

Significant --

func (*ThompsonSampling) Update

func (t *ThompsonSampling) Update(option int, reward float64) error

Update should be used to increment the given option with the given reward amount.

type UpperConfidenceBound

type UpperConfidenceBound struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

UpperConfidenceBound ...

func (*UpperConfidenceBound) Counts

func (u *UpperConfidenceBound) Counts() sam.SliceInt

Counts returns a copy of the counts slice

func (*UpperConfidenceBound) Extend added in v0.1.0

func (u *UpperConfidenceBound) Extend(n int)

Extend --

func (*UpperConfidenceBound) Remove

func (u *UpperConfidenceBound) Remove(option int)

Remove --

func (*UpperConfidenceBound) Rewards

func (u *UpperConfidenceBound) Rewards() sam.SliceFloat64

Rewards returns a copy of the rewards slice

func (*UpperConfidenceBound) Select

func (u *UpperConfidenceBound) Select() int

Select ...

func (*UpperConfidenceBound) Significant added in v0.1.1

func (u *UpperConfidenceBound) Significant(pvalue float64) bool

Significant --

func (*UpperConfidenceBound) Update

func (u *UpperConfidenceBound) Update(option int, reward float64) error

Update should be used to increment the given option with the given reward amount.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL