Last active
August 6, 2018 05:46
-
-
Save FelixChop/eae55ee2636b17dd780cfc5484f3b8ed to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from treeinterpreter import treeinterpreter as ti | |
| for i,row in X.iterrows(): | |
| data_point = pd.DataFrame([row]) | |
| data_point.set_axis(['value_variable']) # Once transposed, it will be the column name | |
| prediction, bias, contributions = ti.predict(rf_model, data_point) | |
| local_interpretation = data_point.append( | |
| pd.DataFrame([[round(c[1],3) for c in contributions[0]]], columns=data_point.columns.tolist(), index=['contribution_variable']) | |
| ).T.sort_values('contribution_variable', ascending=False) | |
| # print(local_interpretation) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment