Esempio n. 1
0
 def write_result(self):
     f_path = myUtil.get_result_fpath(self.dir, self.name)
     w_path = myUtil.get_result_wpath(self.dir, self.name)
     f_content = self.vector_2_str(self.f, to_int=True)
     w_content = self.vector_2_str(self.w)
     with open(f_path, 'w') as f:
         f.write(f_content)
     with open(w_path, 'w') as f:
         f.write(w_content)
Esempio n. 2
0
 def __init__(self, dir, name):
     self.dir = dir
     self.name = name
     allfiles = Util.read_tera_all_csv(dir + name)
     self.raw_filepath = allfiles[allfiles.__len__() - 1]
     self.truth_filepath = Util.get_exist_path(self.raw_filepath)
     self.all_file_path = Util.get_allfile_path(self.dir, self.name)
     self.true_positive = 0
     self.false_positive = 0
     self.true_negative = 0
     self.false_negative = 0
     self.read_ground_truth()
Esempio n. 3
0
 def read_files_num(self):
     filepath = myUtil.get_allfile_path(self.dir, self.name)
     with open(filepath, 'r') as f:
         lines = f.readlines()
     empty_count = 0
     for line in lines:
         if line == "" or line.isspace():
             empty_count += 1
     return lines.__len__() - empty_count
Esempio n. 4
0
 def read_I(self, file1, file2):
     i_path = myUtil.get_i_path(file1, file2)
     vector_i = np.zeros(self.total_file_num)
     with open(i_path, 'r') as f:
         line = f.readline()
     parts = line.split(',')
     index = 0
     while index < parts.__len__():
         vector_i[index] = float(parts[index])
         index += 1
     return vector_i
Esempio n. 5
0
 def read_y(self, filename):
     y_path = myUtil.get_y_path(filename)
     vector_y = np.zeros(self.total_file_num)
     with open(y_path, 'r') as f:
         line = f.readline()
     parts = line.split(',')
     index = 0
     while index < parts.__len__():
         vector_y[index] = float(parts[index])
         index += 1
     return vector_y
Esempio n. 6
0
 def read_l(self, filename, target=False):
     l_path = myUtil.get_l_path(filename, self.sim_type, target)
     with open(l_path, 'r') as f:
         lines = f.readlines()
     matrix_l = np.zeros((self.total_file_num, self.total_file_num),
                         dtype=np.double)
     row = 0
     while row < lines.__len__():
         line = lines[row]
         if line.isspace() or line == "":
             continue
         parts = line.split(',')
         col = 0
         while col < parts.__len__():
             matrix_l[row][col] = float(parts[col])
             col += 1
         row += 1
     return matrix_l
Esempio n. 7
0
 def get_ver_files(self):
     file_dir = self.dir + self.name
     return myUtil.read_tera_all_csv(file_dir)