Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- forest[0].tree_.predict(test_inputs)
- def permutation_importances(rf, x_tr, y_train):
- rf.fit(x_tr,y_train)
- baseline = rf.oob_score_
- imp = []
- for col in x_tr.columns:
- rf_ = rf
- save = x_tr[col]
- x_tr.loc[:,col] = np.random.permutation(save)
- rf_.fit(x_tr, y_train)
- m = rf_.oob_score_
- x_tr.loc[:,col] = save
- imp.append(baseline - m)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement