A message from our CEO about the future of Stack Overflow and Stack Exchange. Read now.
5

The (maximum) number of features is a hyperparameter, i.e. it depends on what you set it to or what the default of the implementation you are using is. In "Introduction to Machine Learning with Python" by Mueller and Guido the authors recommend the following: As described earlier, max_features determines how random each tree is, and a smaller ...


4

_feature_importance of a random forest calculates the average feature importance across all trees in the forest. While tree.feature_importances_ is the feature importance for a single tree. Since feature importance is calculated as the contribution of a feature to maximize the split criterion (or equivalently: minimize impurity of child nodes) higher is ...


4

A random forest model is an agglomeration of Decision Trees. tree.feature_importance_ defines the feature importance for each individual tree, but model.feature_importance_ is the feature importance for the forest as a whole. The docs give the explanation for calculation as: The relative rank (i.e. depth) of a feature used as a decision node in a tree can ...


3

For the Random Forests algorithm, the time complexity for building a complete un-pruned tree is $O(m.n\log(n))$, where $n$ is the number of records/instances and $m$ is the number of variables. The algorithm is embarrassingly parallel so in many cases companies with available resources will simply use sufficient compute nodes to enable the model to run in a ...


2

You need to set bootstrap=False in the random forest to disable the subsampling. (I originally commented because I expected there to be more impediments [in addition to your already-coded random_states and max_features=None], but I guess there aren't any!) You probably don't want to do this in general; by stripping out all the randomness so that the first ...


2

Problem is the way you're onehot encoding. Best practice for any type of encoding : You should train an estimator for Onehot encoding on the training data only, and when encoding test data, you should use the same estimator used on training data. Eg : sklearn.preprocessing.OneHotEncoder does this, and it has a parameter called : handle_unknown. ...


2

To plot feature importance using gridsearch use: x= X_train_v1.columns,y= rf_grid_search_v1.best_estimator_.feature_importances_


1

If you want to see what is the best parameters choosen for your model you can use rf_grid_search_v1.best_estimator_


1

A 1/3 - 2/3 repartition is not that unbalanced. Your problem shouldn't require balancing. The train/test set partition seems to be done correctly, as it seems implied by checking data histograms. Doing that randomly is usually ok, and when it's not it will inflate your test performance with data leakage, which doesn't seems to be the case here. Imo the ...


Only top voted, non community-wiki answers of a minimum length are eligible