somewhat working plots
This commit is contained in:
parent
55898d0e66
commit
554e587ffd
39
plot.py
39
plot.py
|
@ -1,18 +1,40 @@
|
|||
import sys
|
||||
import os
|
||||
import pandas as pd
|
||||
from datetime import datetime
|
||||
import csv
|
||||
import datetime
|
||||
import matplotlib.pyplot as plt
|
||||
import matplotlib.ticker as mtick
|
||||
import matplotlib.dates as mdates
|
||||
from matplotlib.backends.backend_pdf import PdfPages
|
||||
headers = ['Phase', 'Method', 'Start episodes', 'Episodes', 'Sum', 'Mean']
|
||||
|
||||
train_headers = ['timestamp', 'eps_train', 'eps_trained_session', 'sum', 'mean']
|
||||
eval_headers = ['timestamp', 'method', 'eps_train', 'eval_eps_used', 'sum', 'mean']
|
||||
|
||||
model_path = 'models'
|
||||
|
||||
|
||||
def dataframes(model_name):
|
||||
def df_timestamp_to_datetime(df):
|
||||
df['timestamp'] = df['timestamp'].map(lambda t: datetime.datetime.fromtimestamp(t))
|
||||
return df
|
||||
|
||||
log_path = os.path.join(model_path, model_name, 'logs')
|
||||
raw_dfs = [ pd.read_csv(os.path.join(log_path, 'eval.log'), sep=';', names=eval_headers),
|
||||
pd.read_csv(os.path.join(log_path, 'train.log'), sep=';', names=train_headers) ]
|
||||
dfs = [ df_timestamp_to_datetime(df) for df in raw_dfs ]
|
||||
dataframes = {
|
||||
'eval': dfs[0],
|
||||
'train': dfs[1]
|
||||
}
|
||||
return dataframes
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
fig, ax = plt.subplots(1, 1)
|
||||
|
||||
plt.ion()
|
||||
plt.title('Mean over episodes')
|
||||
plt.xlabel('Episodes')
|
||||
plt.xlabel('Episodes trained')
|
||||
plt.ylabel('Mean')
|
||||
plt.grid(True)
|
||||
|
||||
|
@ -22,14 +44,13 @@ ax.set_ylim([-2, 2])
|
|||
plt.show()
|
||||
|
||||
while True:
|
||||
#df = pd.read_csv(sys.stdin, sep=";", names=headers)
|
||||
df = pd.read_csv('log', sep=";", names=headers)
|
||||
df['Total episodes'] = df['Start episodes'] + 100
|
||||
df = pd.read_csv('models/c/logs/eval.log', sep=";", names=eval_headers)
|
||||
df['timestamp'] = df['timestamp'].map(lambda t: datetime.datetime.fromtimestamp(t))
|
||||
|
||||
print(df)
|
||||
|
||||
x = df['Total episodes']
|
||||
y = df['Mean']
|
||||
x = df['eps_train']
|
||||
y = df['mean']
|
||||
|
||||
plt.scatter(x, y, c=[[1, 0.5, 0]])
|
||||
#fig.canvas.draw()
|
||||
|
|
Loading…
Reference in New Issue
Block a user