Created
February 11, 2019 22:27
-
-
Save erykml/a86adf47d1e76edbc7e5eedcf8efdaba 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
| prediction1, bias1, contributions1 = ti.predict(rf, np.array([selected_df[0]]), joint_contribution=True) | |
| prediction2, bias2, contributions2 = ti.predict(rf, np.array([selected_df[1]]), joint_contribution=True) | |
| aggregated_contributions1 = utils.aggregated_contribution(contributions1) | |
| aggregated_contributions2 = utils.aggregated_contribution(contributions2) | |
| res = [] | |
| for k in set(aggregated_contributions1.keys()).union( | |
| set(aggregated_contributions2.keys())): | |
| res.append(([X_train.columns[index] for index in k] , | |
| aggregated_contributions1.get(k, 0) - aggregated_contributions2.get(k, 0))) | |
| for lst, v in (sorted(res, key=lambda x:-abs(x[1])))[:10]: | |
| print (lst, v) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment