def recordAccModel(modelName, dataset): strDeepModel, h, trainTime, prec, recall, strConfMat, predAtK = trainTest( modelName, dataset) currTime = datetime.datetime.now().ctime() numPairs = dataset.getTotalNumPairs() tvt = (round(CF.TRAIN_SPLIT, 2), round(CF.VALIDATION_SPLIT, 2), round(1 - CF.TRAIN_SPLIT - CF.VALIDATION_SPLIT, 2)) dict_index, num_classes = dataset.dict_Cluster_Index, dataset.num_classes if dataset.multiClass: dict_index, num_classes = dataset.dict_Label_Index, dataset.num_labels classMapStr = '\n'.join( [str(j) + ' -> ' + str(i) for i, j in H.sortDictVal(dict_index)]) row = [currTime, trainSet, predictSet, numPairs, tvt, num_classes - 1] row += [ modelName, strDeepModel, predAtK, prec, recall, trainTime, dataset.max_seq_length, dataset.max_vocab_size ] row += [TRAIN_MULT_FACTOR, EPOCHS, CF.EMBEDDING_VECTOR_LENGTH] row += [ classMapStr, strConfMat, roundH(h, 'acc'), roundH(h, 'loss'), roundH(h, 'val_acc'), roundH(h, 'val_loss') ] writeSummary(row)
def getCSV_Conf(self): return [(k, v) for k, v in H.sortDictVal(self.predClasses, reverse=True)]