莫烦Python RL 代码阅读一
- 算法分析
- def build_q_table(n_states, actions)
- def choose_action(state, q_table)
- def rl()
- Python函数功能补漏
- np.random.seed() 函数
- np.zeros(a,b)函数
- pd.DataFrame()函数
- 功能函数
- 根据字典创建
- q_table.iloc()函数
- np.random.uniform() 函数
- .all()函数
- .idmax()函数
- .format()函数
算法分析
不分析如何实现 environment
def build_q_table(n_states, actions)
def build_q_table(n_states, actions):table = pd.DataFrame(np.zeros((n_states, len(actions))), # q_table initial valuescolumns=actions, # actions's name)# print(table) # show tablereturn table
pd.DataFrame()
np.zeros(a,b)
在下方版块有整理
此函数用于构建n行,len(actions)列的Q-table,算是典型的表格型方法
def choose_action(state, q_table)
def choose_action(state, q_table):# This is how to choose an actionstate_actions = q_table.iloc[state, :]if (np.random.uniform() > EPSILON) or