MCPcopy Index your code
hub / github.com/lazyprogrammer/machine_learning_examples / get_scaler

Function get_scaler

rl/linear_rl_trader.py:29–43  ·  view source on GitHub ↗
(env)

Source from the content-addressed store, hash-verified

27
28
29def get_scaler(env):
30 # return scikit-learn scaler object to scale the states
31 # Note: you could also populate the replay buffer here
32
33 states = []
34 for _ in range(env.n_step):
35 action = np.random.choice(env.action_space)
36 state, reward, done, info = env.step(action)
37 states.append(state)
38 if done:
39 break
40
41 scaler = StandardScaler()
42 scaler.fit(states)
43 return scaler
44
45
46

Callers 1

Calls 2

stepMethod · 0.45
fitMethod · 0.45

Tested by

no test coverage detected