[Solved] How to calculate precision and recall for two nested arrays [closed]
You have to flatten your lists as shown here, and then use classification_report from scikit-learn: correct = [[‘*’,’*’],[‘*’,’PER’,’*’,’GPE’,’ORG’],[‘GPE’,’*’,’*’,’*’,’ORG’]] predicted = [[‘PER’,’*’],[‘*’,’ORG’,’*’,’GPE’,’ORG’],[‘PER’,’*’,’*’,’*’,’MISC’]] target_names = [‘PER’,’ORG’,’MISC’,’LOC’,’GPE’] # leave out ‘*’ correct_flat = [item for sublist in correct for item in sublist] predicted_flat = [item for sublist in predicted for item in sublist] from sklearn.metrics import classification_report print(classification_report(correct_flat, … Read more