-
Notifications
You must be signed in to change notification settings - Fork 1
/
result_class.py
34 lines (29 loc) · 1.11 KB
/
result_class.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"""
This is a part of the autonomous car project.
This simulates how to apply Reinforcement Learning in dynamic obstacles avoidance for a self-driving car.
author: Binh Tran Thanh / email:thanhbinh@hcmut.edu.vn or thanhbinh.hcmut@gmail.com
"""
import csv
import pandas as pd
class Result_Log:
def __init__(self, header_csv = ["Reached goal","Car status"]):
self.results_data = []
self.header_csv = header_csv
''' save result in to list '''
def add_result(self, result):
self.results_data.append (result)
''' set header '''
def set_header (self, header_csv):
self.header_csv = header_csv
''' write result to csv file '''
def write_csv(self, file_name):
f = open(file_name, 'w', newline='', encoding="utf-8")
writer = csv.writer(f, delimiter=",")
writer.writerow(self.header_csv)
for result_items in self.results_data:
writer.writerow(result_items)
f.close()
''' read csv as dataframe '''
def read_csv_as_dataframe(self, result_file):
# read result as frame
return pd.read_csv(result_file)