Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. forest[0].tree_.predict(test_inputs)
  2.  
  3. def permutation_importances(rf, x_tr, y_train):
  4. rf.fit(x_tr,y_train)
  5. baseline = rf.oob_score_
  6. imp = []
  7. for col in x_tr.columns:
  8. rf_ = rf
  9. save = x_tr[col]
  10. x_tr.loc[:,col] = np.random.permutation(save)
  11. rf_.fit(x_tr, y_train)
  12. m = rf_.oob_score_
  13. x_tr.loc[:,col] = save
  14. imp.append(baseline - m)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement