aneesh-joshi / LSTM_POS_Tagger

A simple POS Tagger made using a Bidirectional LSTM using keras trained on the Brown Corpus
34 stars 19 forks source link

accuracy by tag #13

Open celsofranssa opened 6 years ago

celsofranssa commented 6 years ago

Hello,

Is there an approach to measure the accuracy by TAG?

Thanks.

celsofranssa commented 6 years ago

@aneesh-joshi Sklearn classification-report can calculate accuracy each tag. Could you show how to put it in action over model_evaluation.py? Thanks.

aneesh-joshi commented 5 years ago

Hey @Ceceu Sorry for responding so late. I hope it's not too late.

Yes, I believe it can be done.

From the sklearn website:

>>> from sklearn.metrics import classification_report
>>> y_true = [0, 1, 2, 2, 2]
>>> y_pred = [0, 0, 2, 2, 1]
>>> target_names = ['class 0', 'class 1', 'class 2']
>>> print(classification_report(y_true, y_pred, target_names=target_names))

So, from the repo, you just need y_pred and y_true. y_true will be the actual tags and y_pred will be the predicted tags. You can do it on a sentence by sentence basis.

If you figure something out, you can make a PR with a separate file.