fabrahman / Emo-Aware-Storytelling

Code repository for our EMNLP 2020 long paper "Modeling Protagonist Emotions for Emotion-Aware Storytelling" (https://arxiv.org/abs/2010.06822)
MIT License
19 stars 6 forks source link

ImportError: cannot import name 'accuracy_jaccord' #3

Closed swidi closed 3 years ago

swidi commented 3 years ago

I installed fast_bert as described but there is one particular import that is not working:

>>> from fast_bert.metrics import accuracy_jaccord
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'accuracy_jaccord'

This leads to run_bert_classifier.py failing.

Do you know if a very specific version of fast_bert or sklearn are required? No version is specified in fast_berts' requirements.txt

xinli2008 commented 3 years ago

Yes,I found the same error! i doubt if the author of fast_bert update the code ? And have you solved the question ? Yours sincerely! @swidi

fabrahman commented 3 years ago

@swidi @shaoniana1997 Please add the following function in the metrics.py :

def accuracy_jaccord(y_pred: Tensor, y_true: Tensor, thresh: float = CLASSIFICATION_THRESHOLD, sigmoid: bool = True):
    if sigmoid:
        y_pred = y_pred.sigmoid()
    return jaccard_score(y_pred > thresh, y_true.bool(), average='samples')

I am closing this issue for now. Feel free to reopen.

xinli2008 commented 3 years ago

thank you for your timely reply!

xinli2008 commented 2 years ago

when i use the accuracy_jaccord to evaluate ,if always reminds the information : TypeError: accuracy_jaccord() got an unexpected keyword argument 'labels' can you give me some useful advice? @fabrahman