Guest User

Untitled

a guest
Jun 18th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. from sklearn.ensemble import forest
  2.  
  3. def set_rf_samples(n):
  4. """ Changes Scikit learn's random forests to give each tree a random sample of
  5. n random rows.
  6. """
  7. forest._generate_sample_indices = (lambda rs, n_samples:
  8. forest.check_random_state(rs).randint(0, n_samples, n))
  9.  
  10. def reset_rf_samples():
  11. """ Undoes the changes produced by set_rf_samples.
  12. """
  13. forest._generate_sample_indices = (lambda rs, n_samples:
  14. forest.check_random_state(rs).randint(0, n_samples, n_samples))
Add Comment
Please, Sign In to add comment