How Many Features Are Used in Random Forest When max_features is not an integer?
The argument for the number of features gets passed down to the BaseDecisionTree class. Looking at the code, you can see that the value that is used is calculated by first taking log with base two and then converting it to an integer (i.e. rounding it).
if self.max_features == &quot;auto&quot;:
    if is_classification:
        max_features = max(1, int(np.sqrt(self.n_features_)))
    else:
        max_features = self.n_features_
elif self.max_features == &quot;sqrt&quot;:
    max_features = max(1, int(np.sqrt(self.n_features_)))
elif self.max_features == &quot;log2&quot;:
    max_features = max(1, int(np.log2(self.n_features_)))
else:
    raise ValueError(&quot;Invalid value for max_features. &quot;
                     &quot;Allowed string values are 'auto', &quot;
                     &quot;'sqrt' or 'log2'.&quot;)