-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor evaluation #1671
Merged
Merged
Refactor evaluation #1671
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR makes a number of refactorings to the evaluation routines in Flair. In short: whenever possible, we now use the evaluation methods of sklearn (instead of our own implementations which kept getting issues). This applies to text classification and (most) sequence tagging.
A notable exception is "span-F1" which is used to evaluate NER because there is no good way of counting true negatives. After this PR, our implementation should now exactly mirror the original
conlleval
script of the CoNLL-02 challenge. In addition to using our reimplementation, an output file is now automatically generated that can be directly used with theconlleval
script.In more detail, this PR makes the following changes:
Span
is now a list ofToken
and can now be iterated like a sentenceflair.DataLoader
is now used throughoutevaluate()
interface in theModel
base class is changed so that it no longer requires a data loader, but ran run either over list ofSentence
or aDataset
SequenceTagger.evaluate()
now explicitly distinguishes between F1 and Span-F1. In the latter case, no TN are counted (closes Getting always same number of TN and TP for multilabel classification #1663) and a non-sklearn implementation is used.DocumentPoolEmbeddings
In the
evaluate()
method of theSequenceTagger
andTextClassifier
, we now explicitly call the.predict()
method. To enable this, we made some changes to thepredict()
interface, namely you can now optionally specify the "label name" of the predicted label:This may be useful if you have multiple ner taggers and wish to tag the same sentence with them. Then you can distinguish between the tags by the taggers. It is also now no longer possible to give the predict method a string - you now must pass a sentence.
This PR also makes it possible to set seeds when loading and downsampling corpora, so that the sample is always the same: