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

Avoid Deepcopy on Tree and ParticleTree #47

Merged
merged 2 commits into from
Jan 23, 2023

Conversation

fjloyola
Copy link
Contributor

To avoid deepcopy we have to change some constructors and implement method copy, here is the list of all the changes:

  • Implement a constructor of Tree with all the attributes(tree_structure, idx_leaf_nodes and output);
  • Create the class method new_tree with the previous behavior of the constructor;
  • Change the implementation of copy on Tree, avoiding deepcopying all and just deepcopying the output;
  • Improve method trim(), previously we copy all and then we delete the attributes that we do not need, now we just create the tree copying the attributes that we care;
  • Instead of creating an empty list and append each particle we create an comprehensive list; We implement the method copy on ParticleTree, instead of deepcopying;

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 85 sec 74 sec 12,94%
40 123 sec 99 sec 19,51%
60 160 sec 128 sec 20,00%
100 20 115 sec 103 sec 10,43%
40 207 sec 154 sec 25,60%
60 262 sec 209 sec 20,23%
200 20 212 sec 164 sec 22,64%
40 338 sec 267 sec 21,01%
60 519 sec 378 sec 27,17%
coal 50 20 67 sec 57 sec 14,93%
40 92 sec 83 sec 9,78%
60 124 sec 104 sec 16,13%
100 20 97 sec 85 sec 12,37%
40 154 sec 135 sec 12,34%
60 209 sec 181 sec 13,40%
200 20 159 sec 138 sec 13,21%
40 264 sec 229 sec 13,26%
60 381 sec 319 sec 16,27%
friedman 50 20 78 sec 65 sec 16,67%
40 120 sec 91 sec 24,17%
60 171 sec 115 sec 32,75%
100 20 118 sec 93 sec 21,19%
40 216 sec 144 sec 33,33%
60 304 sec 200 sec 34,21%
200 20 199 sec 150 sec 24,62%
40 380 sec 246 sec 35,26%
60 556 sec 354 sec 36,33%
space_influenza 50 20 79 sec 66 sec 16,46%
40 115 sec 95 sec 17,39%
60 158 sec 125 sec 20,89%
100 20 109 sec 101 sec 7,34%
40 198 sec 153 sec 22,73%
60 262 sec 207 sec 20,99%
200 20 178 sec 158 sec 11,24%
40 310 sec 271 sec 12,58%
60 444 sec 381 sec 14,19%

…, idx_leaf_nodes and output);

Create the class method new_tree with the previous behaviour of the constructor;
Change the implementation of copy on Tree, avoiding deepcopying all and just deepcopying the output;
Improve method trim(), previously we copy all and then we delete the atributes that we do not need, now we just create the tree copying the atributes that we care;
Insted of creating an empty list and append each particle we create an comprehensive list;
We implement the method copy on ParticleTree, instead of deepcopying;
pymc_bart/pgbart.py Outdated Show resolved Hide resolved
pymc_bart/tree.py Outdated Show resolved Hide resolved
@fjloyola fjloyola marked this pull request as ready for review January 23, 2023 14:40
Copy link
Member

@aloctavodia aloctavodia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@aloctavodia aloctavodia merged commit 152063c into pymc-devs:main Jan 23, 2023
@fjloyola fjloyola deleted the feature/avoid-deepcopy branch January 23, 2023 15:27
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