Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor and @njit on methods #54

Merged

Conversation

fjloyola
Copy link
Contributor

@fjloyola fjloyola commented Jan 27, 2023

Refactor and @njit on methods:

  • adding @njit in the methods get_new_idx_data_points and draw_leaf_value;
  • avoid creating variables when it is posible;
  • change the get_split_variables() to be a generator;
  • instead of creating Particle and then put the value of the kfactor we refactor constructor to have the default value in 0.75 as a parameter;
  • grow_tree now returns the new leaf idx;
  • in grow_tree, change the if else sentence for early return, also, instead of creating new node split node and delete the leaf value there is a new method grow_leaf_node;
  • in the draw_leaf_value we simplify the expresions;
  • in _travearse_tree instead of having two returns we create a variable next_node;

Tested Mac with chip M1, 8 cores and 16 gb of ram having the next results:

Configuration version performances improvements
model name tree º particle º current new
biking 50 20 74 sec 68 sec 8,11%
40 99 sec 93 sec 6,06%
60 128 sec 121 sec 5,47%
100 20 103 sec 96 sec 6,80%
40 154 sec 140 sec 9,09%
60 209 sec 200 sec 4,31%
200 20 164 sec 155 sec 5,49%
40 267 sec 255 sec 4,49%
60 378 sec 359 sec 5,03%
coal 50 20 57 sec 57 sec 0,00%
40 83 sec 81 sec 2,41%
60 104 sec 94 sec 9,61%
100 20 85 sec 77 sec 9,41%
40 135 sec 108 sec 20,00%
60 181 sec 145 sec 19,89%
200 20 138 sec 128 sec 7,24%
40 229 sec 203 sec 11,35%
60 319 sec 278 sec 12,85%
friedman 50 20 65 sec 57 sec 12,31%
40 91 sec 75 sec 17,58%
60 115 sec 96 sec 16,52%
100 20 93 sec 79 sec 15,05%
40 144 sec 118 sec 18,06%
60 200 sec 162 sec 19,00%
200 20 150 sec 125 sec 16,67%
40 246 sec 202 sec 17,89%
60 354 sec 279 sec 21,19%
space_influenza 50 20 66 sec 59 sec 10,61%
40 95 sec 77 sec 18,95%
60 125 sec 101 sec 19,20%
100 20 101 sec 81 sec 17,65%
40 153 sec 126 sec 17,65%
60 207 sec 171 sec 17,39%
200 20 158 sec 134 sec 15,19%
40 271 sec 220 sec 18,82%
60 381 sec 313 sec 17,85%

change the get_split_variables() to be a generator;
instead of creating Particle and then put the value of the kfactor we refactor constructor to have the default value in 0.75 an the parameter;
grow_tree now returns the new leaf idx;
in grow_tree, change the if else sentence for early return, also, instead of creating new node split node and delete the leaf value there is a new method grow_leaf_node;
in the draw_leaf_value we simplify the expresions;
in _travearse_tree instead of having two returns we create a variable next_node;
adding @njit in the methods get_new_idx_data_points and draw_leaf_value;
@fjloyola fjloyola force-pushed the feature/refactor_and_njit_on_methods branch from fcc3493 to d011bde Compare January 27, 2023 12:26
@aloctavodia aloctavodia merged commit ff22efe into pymc-devs:main Feb 1, 2023
@fjloyola fjloyola deleted the feature/refactor_and_njit_on_methods branch February 1, 2023 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants