MCPcopy Create free account
hub / github.com/lazyprogrammer/machine_learning_examples / epsilon_greedy

Function epsilon_greedy

rl/approx_prediction.py:20–27  ·  view source on GitHub ↗
(greedy, s, eps=0.1)

Source from the content-addressed store, hash-verified

18
19
20def epsilon_greedy(greedy, s, eps=0.1):
21 # we'll use epsilon-soft to ensure all states are visited
22 # what happens if you don't do this? i.e. eps=0
23 p = np.random.random()
24 if p < (1 - eps):
25 return greedy[s]
26 else:
27 return np.random.choice(ALL_POSSIBLE_ACTIONS)
28
29
30def gather_samples(grid, n_episodes=10000):

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected