I used Random Forests recently for an imbalanced dataset and wanted to give it class-weights. My understanding of class weight so far is that, if we pass ‘balanced’ to it, they(classes) are adjusted inversely to the proportion of their frequency. One specific question that I have regarding class weights is ‘At what point are class weights applied?’

For example, is it calculated once before fitting? or is it calculated it at individual tree level? or does it recalculate it at each individual split?

Let’s say for example, after splitting we are left with 10,000 samples on the left node. Are the class weights recalculated at this point as the ratio of classes may have changed (say from 1:10 to 1:5)?