Created
June 1, 2018 10:07
-
-
Save FelixChop/9185d1968531a79593f469e743da3467 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, utils | |
| prediction, bias, contributions = ti.predict(rf_model, data_to_analyze[X_test.columns]) | |
| # Print the local interpretation tables | |
| for i in range(10): | |
| print("Bias: " +str(bias[i][1])) | |
| data_to_analyze[X_test.columns].append(pd.DataFrame( | |
| [[round(c[1],3) for c in contributions[i]]], | |
| columns=X_test.columns, | |
| index=['importance'])).T.sort_values('importance', ascending=False) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment