def __init__(self, filename): csvData = readData.readCSV(self, filename) self.data = csvData.data self.Class = csvData.Class self.attributes = csvData.attributes self.attributeNames = csvData.attributeNames self.trainingValues = csvData.trainingValues self.root = self.VIH(self.trainingValues, self.Class, self.attributes)
def __init__(self, filename): csvData = readData.readCSV(self, filename) self.Class = csvData.Class self.data = csvData.data
tot_fn = np.zeros(10) tot_fp = np.zeros(10) tot_time = np.zeros(10) for seed in range(10): detail_csv = open(directory + "/detail_results.csv", "a") csvWriter_detail = csv.writer(detail_csv, delimiter=',') try: os.remove(directory + '/result_N' + str(num_nurses) + '_seed' + str(seed) + '.csv') except OSError: pass start = time.clock() rd.learnConstraints(dataDir, numSol, num_nurses, 1, directory, numFiles, seed) end = time.clock() data = rd.readCSV(directory + '/result_N' + str(num_nurses) + '_seed' + str(seed) + '.csv') data_transpose = list(zip(*data)) data_int = np.zeros( [len(data_transpose), len(data_transpose[0]) - 1]) for i in range(len(data_transpose)): for j in range(1, len(data_transpose[i])): if data_transpose[i][j] != '': data_int[i, j - 1] = int(data_transpose[i][j]) bounds_learned = np.zeros([num_constrType, num_constr]) k = 0 for i in range(len(data_transpose)): if (i + 1) % 7 != 0:
numFiles, directory + "/solutions", constrList, bounds) try: os.remove(directory + '/result_N' + str(num_nurses) + '_forAll.csv') except OSError: pass rd.learnConstraintsForAll(dataDir, num_nurses, 1, directory) bounds_prev = np.zeros([num_constrType, num_constr]) objVal = 0 minObjVal = 0 i = 0 for fl in glob.glob(directory + "/solutions" + "/*objVal" + str(num_nurses) + "*.csv"): tmp = float(rd.readCSV(fl)[0][0]) if i == 0: minObjVal = tmp else: minObjVal = min(minObjVal, tmp) objVal += tmp i += 1 objVal = objVal / numFiles data = rd.readCSV(directory + '/result_N' + str(num_nurses) + '_forAll.csv') data_transpose = list(zip(*data)) data_int = np.zeros([len(data_transpose), len(data_transpose[0]) - 1]) for i in range(len(data_transpose)): for j in range(1, len(data_transpose[i])): if data_transpose[i][j] != '': data_int[i, j - 1] = int(data_transpose[i][j])