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

Find the features and weights impacting the label prediction #34

Open
ctrado18 opened this issue Dec 3, 2018 · 2 comments
Open

Find the features and weights impacting the label prediction #34

ctrado18 opened this issue Dec 3, 2018 · 2 comments

Comments

@ctrado18
Copy link

ctrado18 commented Dec 3, 2018

Hi,

you can get the marginal probabilities for each label, but I want to know the graph. Meaning for every feature node I want the tranition probability.

How can I do that? I see that you can get state_features, but I want to be more precise and want to know the impact of each feature for the current sentence.

Is the resulting marginal then just the average of all weights?

@ctrado18 ctrado18 changed the title FInd the features and weights impacting the label prediction Find the features and weights impacting the label prediction Dec 3, 2018
@skurzhanskyi
Copy link

I would recommend you to check eli5 library. They have sklearn_crfsuite weights explanation.

@ctrado18
Copy link
Author

I have trained a german CRF.
I looked at the feature and weights to analyse why and why not the entity is recognised.

E.g. for this sentences. There it recognises correctly the word 'Leistung' but also ''gezahlt" which I don't want.

'wie viel Leistung bekomm ich gezahlt?'

Then I looked at the features predicting the word 'gezahlt':

features
[('-1:prefix5', 'ich'), ('-1:suffix3', 'ich'), ('0:bias', 'bias'), ('EOS', True)]

here just suffix3 and prefix5.

The individual weights are (feature, weight, label):

-1:prefix5:ich weight:0.255969 label: U-Leistung
-1:prefix5:ich weight:-0.255969 label: O
-1:suffix3:ich weight:0.255969 label: U-Leistung
-1:suffix3:ich weight:-0.255969 label: O
0:bias:bias weight:1.512877 label: O
0:bias:bias weight:-1.512877 label: U-Leistung

SUM WEIGHT LEISTUNG
-1.000939
SUM WEIGHT O
1.000939

This gives in the sum same weights for entitiy Leistung and label O.
But why does the word 'gezahlt' has probability of 77% at the end in prediction?

And I thought negative weights are downgrading the proper label (why is then at all this word an entity)

I hope you can clarify a bit?

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