mirror of
https://gitlab.rlp.net/mobitar/ReCo.jl.git
synced 2024-12-21 00:51:21 +00:00
Added latex_table
This commit is contained in:
parent
839e766206
commit
a57bebbcb7
1 changed files with 44 additions and 0 deletions
44
src/RL/latex_table.jl
Normal file
44
src/RL/latex_table.jl
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
using DataFrames
|
||||||
|
using PrettyTables: pretty_table
|
||||||
|
|
||||||
|
function latex_table(dataframe, filename::String; path="exports/$filename")
|
||||||
|
open(path, "w") do f
|
||||||
|
pretty_table(f, dataframe; backend=:latex, nosubheader=true, alignment=:c)
|
||||||
|
end
|
||||||
|
|
||||||
|
return nothing
|
||||||
|
end
|
||||||
|
|
||||||
|
function latex_rl_table(env_helper, filename)
|
||||||
|
table = env_helper.shared.agent.policy.learner.approximator.table
|
||||||
|
|
||||||
|
for col in 1:size(table)[2]
|
||||||
|
table[:, col] ./= sum(table[:, col])
|
||||||
|
end
|
||||||
|
|
||||||
|
table .= round.(table, digits=2)
|
||||||
|
|
||||||
|
state_spaces_labels = env_helper.shared.env.shared.state_spaces_labels
|
||||||
|
states = AbstractString[]
|
||||||
|
for i in state_spaces_labels[1]
|
||||||
|
for j in state_spaces_labels[2]
|
||||||
|
push!(states, i * " ; " * j)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
action_spaces_labels = env_helper.shared.env.shared.action_spaces_labels
|
||||||
|
actions = AbstractString[]
|
||||||
|
|
||||||
|
for i in action_spaces_labels[1]
|
||||||
|
for j in action_spaces_labels[2]
|
||||||
|
push!(actions, i * "; " * j)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
df = DataFrame(table, states)
|
||||||
|
insertcols!(df, 1, :Actions => actions)
|
||||||
|
|
||||||
|
latex_table(df, filename)
|
||||||
|
|
||||||
|
return nothing
|
||||||
|
end
|
Loading…
Reference in a new issue