learners package

Submodules

learners.errors module

class learners.errors.ErrorMessages[source]

Bases: object

static get(code: ErrorsCodes) str[source]
class learners.errors.Errors[source]

Bases: object

static create_error(error_code: ErrorsCodes) LearnerResponse[source]
class learners.errors.ErrorsCodes(value)[source]

Bases: Enum

An enumeration.

ERROR_LEARNER_NOT_SUPPORTED = 0
ERROR_TRAIN_ENTRY_ALREADY_IN_LIST = 1

learners.learner module

class learners.learner.Learner[source]

Bases: object

class Type(value)[source]

Bases: Enum

An enumeration.

SARSA_QTABLE = 'SarsaQTable'
act(entry: ActEntry) LearnerResponse[source]

Implement the generic action decision from the state

get_name() str[source]
get_parameters() dict[source]
get_stats() dict[source]
get_weights() dict[source]
classmethod instance(learner='', parameters=None)[source]
reset()[source]

Restart learner ex-novo resetting parameters and value function/td form

set_learner(name='', parameters=None)[source]
set_parameters(new_parameters: dict) bool[source]
start()[source]

Start the learner thread, if any

train(entry: LearningEntry) LearnerResponse[source]

Implement the generic train step from state, action and reward

learners.learner_sarsa_qtable module

class learners.learner_sarsa_qtable.SarsaQTable(actions_n=2, alpha=0.01, beta=0.01, window_size=5, epsilon_start=0.9, epsilon_min=0.1, epsilon_decay=0.99, epsilon_decay_enabled=True, entry_missing_max_attempts=100, parameters_dict=None)[source]

Bases: object

PARAM_ACTIONS_N = 'actions_n'
PARAM_ALPHA = 'alpha'
PARAM_BETA = 'beta'
PARAM_ENTRY_MISSING_MAX_ATTEMPTS = 'entry_missing_max_attempts'
PARAM_EPSILON_DECAY = 'epsilon_decay'
PARAM_EPSILON_DECAY_ENABLED = 'epsilon_decay_enabled'
PARAM_EPSILON_MIN = 'epsilon_min'
PARAM_EPSILON_START = 'epsilon_start'
PARAM_WINDOW_SIZE = 'window_size'
act(entry: ActEntry) LearnerResponse[source]

Returns the action that maximizes the q_sa

get_parameters() dict[source]
get_stats() dict[source]
get_weights() dict[source]
reset()[source]
set_parameters(new_parameters: dict) bool[source]
start()[source]

Start the learner thread, if any

train(entry: LearningEntry) LearnerResponse[source]

learners.models module

class learners.models.LearnerResponse[source]

Bases: object

action: float
eps: float
error: bool = False
error_code: int
error_message: str

Module contents