Skip to content
Snippets Groups Projects
Commit 7ccb5f7e authored by Alice Brenon's avatar Alice Brenon
Browse files

Add a script to generate reports and draw a confusion matrix

parent 7ea8651f
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env python3
from EDdA.classification import heatmap
from EDdA.store import preparePath
import GEODE.discursive as discursive
import pandas
from sklearn.metrics import classification_report, confusion_matrix
from sys import argv
def evaluate(truth, predictions, outputDirectory):
matrix = confusion_matrix(truth,
predictions,
labels=list(discursive.functions),
normalize='true')
heatmap(matrix,
preparePath(f"{outputDirectory}/confusion.png"),
labels=discursive.functions)
with open(f"{outputDirectory}/report.json", 'w') as json:
print(classification_report(truth, predictions, output_dict=True),
file=json)
with open(f"{outputDirectory}/report.txt", 'w') as txt:
print(classification_report(truth, predictions),
file=txt)
if __name__ == '__main__':
truth = pandas.read_csv(argv[1], sep='\t')
predictions = pandas.read_csv(argv[2], sep='\t')
evaluate(truth['paragraphFunction'], predictions['label'], argv[3])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment