Skip to content

Instantly share code, notes, and snippets.

@khaledadrani
Created January 17, 2022 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save khaledadrani/2f86a5d64c5f3fd10b2ce931fa87a812 to your computer and use it in GitHub Desktop.
Save khaledadrani/2f86a5d64c5f3fd10b2ce931fa87a812 to your computer and use it in GitHub Desktop.
# Evaluation of trained model
# Start remove 'O' labels
labels = list(crf.classes_)
labels.remove('O')
print("trained labels :",labels)
# start prediction and calculate f-score
y_pred = crf.predict(X_test)
print (metrics.flat_f1_score(y_test, y_pred,
average='weighted', labels=labels,zero_division=True))
# Inspect evaluation per class
# group B and I results
sorted_labels = sorted(
labels,
key=lambda name: (name[1:], name[0])
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment