-
Notifications
You must be signed in to change notification settings - Fork 2
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
hello, can you help me to get the picture like your example2.png in the ./elih/doc/ ? #2
Comments
Hi @thpatty, sure, did you try this code? from eli5 import explain_prediction
from eli5 import formatters
idx = 45
exp = elih.HumanExplanation(
explanation=explain_prediction(clf, valid_xs[idx], vec=vec), # an ELI5 Explanation object
rules_layers=[{
# 1st layer -- variables back from dummy encoding
'Pclass': 'Pclass=*',
'Sex': 'Sex=*',
'Source port': 'Embarked=*',
'Cabin': 'Cabin=*',
'Ticket #': 'Ticket=*'
}, {
# 2nd layer -- grouping advanced features
'Family': ['Parch', 'SibSp'],
'Cabin & location': ['Cabin', 'Fare', 'Ticket #', 'Pclass'],
'Person': ['Sex', 'Age']
}],
additional_features=valid_xs_no_transform[idx], # raw input data (before preprocessing)
dictionary={
'Sex': {
'label': 'Sex',
'value_from': 'Sex',
'formatter': elih.formatters.mapper({
'female': 'female',
'male': 'male'
})
},
'Fare': {
'label': u'Ticket fare',
'formatter': elih.formatters.value_simplified(decimals=0, unit="$")
},
'Cabin': {
'label': u'Cabin number',
'value_from': 'Cabin',
'formatter': elih.formatters.text()
},
'Age': {
'label': u'Age',
'formatter': (lambda a: '{} yrs'.format(int(a)))
},
'Parch': {
'label': u'# parents & children onboard',
'formatter': elih.formatters.integer()
},
'SibSp': {
'label': u'# siblings & spouse onboard',
'formatter': elih.formatters.integer()
},
'Source port': {
'label': u"Embarkment port",
'value_from': 'Embarked',
'formatter': elih.formatters.mapper({
'C': 'Cherbourg',
'Q': 'Queenstown',
'S': 'Southampton'
})
},
'Ticket #': {
'label': u'Ticket number',
'formatter': elih.formatters.text(),
'value_from': 'Ticket'
},
'Pclass': {
'label': u'Passenger class',
'value_from': 'Pclass',
'formatter': elih.formatters.text()
}
},
scoring=(lambda x: 10-10*elih.scoring.sigmoid(3*x)),
interpretors={
'PASSENGER_ALONE': {
'assert': lambda v: v['Parch'] == 0 and v['SibSp'] == 0,
'interpretation': lambda v: 'Passenger is travelling alone',
'not_interpretation': lambda v: 'Passenger is not travelling alone'
},
'PASSENGER_ABOVE_50': {
'assert': lambda v: v['Age'] > 50,
'interpretation': lambda v: 'Passenger is above 50 ({})'.format(v['Age']['formatted_value'])
}
}
)``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks so much.
The text was updated successfully, but these errors were encountered: