I have a log file that I would like to parse and plot using matplotlib. After skipping the first 6 lines, I have data of interest. e.g. my log file looks like this:
# 2014-05-09 17:51:50,473 - root - INFO - Epoch = 1, batch = 216, Classif Err = 52.926, lg(p) -1.0350
# 2014-05-09 17:51:53,749 - root - INFO - Test set error = 37.2317
I want to make a plot of the Classif Err vs Test set error for each Epoch.
My first attempt at this:
import numpy
from numpy import *
from pylab import *
f1 = open('log.txt', 'r')
FILE = f1.readlines()
f1.close()
for line in FILE:
line = line.strip()
if ('Epoch' in line):
epoch += line.split('Epoch = ')
elif('Test set error' in line):
test_err += line.split('Test set error = ')
I see this error:
Traceback (most recent call last):
File "logfileparse.py", line 18, in <module>
epoch += line.split('Epoch = ')
NameError: name 'epoch' is not defined
epoch=""and I think every think will work just fine.