Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def load_input(input_file):
lines = read(input_file).strip().split("\n")
content = [line.split("\t")[0] for line in lines]
content = u" ".join(content)
return content
def load_output(input_file):
lines = [text.split("\t") for text in read(input_file).strip().split("\n")]
output = [tuple(item) for item in lines]
return output
def load_input(input_file):
lines = read(input_file).strip().split("\n")
if lines[0][0] == "#":
lines = lines[1:]
content = [line.split("\t")[0] for line in lines]
content = u" ".join(content)
return content
def load_output(input_file):
lines = read(input_file).strip().split("\n")
if lines[0][0] == "#":
lines = lines[1:]
text = "\n".join(lines)
return text
def convert_cm_to_log(cm, labels, line=5):
cm = cm.tolist()
# cm = [" ".join([("%-" + str(line) + "s") % labels[index]] + map(lambda i: ("%" + str(line) + "d") % i, row)) for index, row in enumerate(cm)]
cm_ = []
for index, row in enumerate(cm):
content = " ".join([("%-" + str(line) + "s") % labels[index]] + map(lambda i: ("%" + str(line) + "d") % i, row))
cm_.append(content)
title = " " * (line + 1) + " ".join(map(lambda i: ("%" + str(line) + "s") % i, labels))
cm.insert(0, title)
return cm
# results = json.loads(read(join("logs", "20171006_153955", "result.json")))
results = json.loads(read(join("logs", "20171006_161437", "result.json")))
print(0)
actual = results["actual"]
expected = results["expected"]
labels = list(set(expected).union(set(actual)))
cm = confusion_matrix(expected, actual, labels)
cm = convert_cm_to_log(cm, labels)
pprint(cm, indent=2)