Skip to content
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

classification report throws 'int' object has no attribute 'startswith' #87

Open
raomanohar opened this issue Feb 22, 2022 · 1 comment

Comments

@raomanohar
Copy link

I am trying to print a Classification report and I get the below error:
I did check if any int values are passed in the list and there were none, infact I also made sure to convert them to string before saving them in a list. Please advise where am I going wrong.

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-160-2ad87943346a> in <module>
----> 1 print(classification_report(correctLabels, predLabels))

~\Anaconda3\lib\site-packages\seqeval\metrics\sequence_labeling.py in classification_report(y_true, y_pred, digits, suffix, output_dict, mode, sample_weight, zero_division, scheme)
    677                   )
    678 
--> 679     target_names_true = {type_name for type_name, _, _ in get_entities(y_true, suffix)}
    680     target_names_pred = {type_name for type_name, _, _ in get_entities(y_pred, suffix)}
    681     target_names = sorted(target_names_true | target_names_pred)

~\Anaconda3\lib\site-packages\seqeval\metrics\sequence_labeling.py in get_entities(seq, suffix)
    180     chunks = []
    181     for i, chunk in enumerate(seq + ['O']):
--> 182         _validate_chunk(chunk, suffix)
    183 
    184         if suffix:

~\Anaconda3\lib\site-packages\seqeval\metrics\sequence_labeling.py in _validate_chunk(chunk, suffix)
    168 
    169         else:
--> 170             if not chunk.startswith(('B-', 'I-', 'E-', 'S-')):
    171                 warnings.warn('{} seems not to be NE tag.'.format(chunk))
    172 

AttributeError: 'int' object has no attribute 'startswith'
@RajMaster1612
Copy link

you are passing int as labels just convert it into string
print([str(x) for x in labels])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants