1

I want to optimize a Random Forest classifier. So, I plotted an OOB error(the code is available in scikit). From this plot, I want to pick the 2 variables (n_estimators and max_features) that give the lowest OOB error. And then use those them to optimize the classifier (a clf.fit).

From the curve it can be seen that with 170 n_estimators and 5 max_features, I get the lowest OOB. But how can I send these 2 values as a clf.fit to the RandomForest? I want to use this technique instead of RandomSearch or GridSearch.

Any idea on where to start?

Thank you. OOB error

Aizzaac
  • 3,146
  • 8
  • 29
  • 61
  • the RF classifier must be initialized before using the fit function. Therefore you will initialize your RF with the parameters you deem to be the best such as described in the documentation: http://scikit-learn.org/stable/modules/generated/sklearn.ensemble.RandomForestClassifier.html clf = RandomForestClassifier(n_estimators=BEST_N, max_features=BEST_F) or to most concrete: clf = RandomForestClassifier(n_estimators=170, max_features=5). Then you are using the fit function to train the classifier. – Nikolas Rieble Mar 08 '17 at 15:23
  • @Nikolas Rieble Hi. I understand that. But is there any "methods", "parameters" to get that information and fit it in the classifier? As I have lots of datasets and I do not want to visually determine the n_estimators nor the max_features. – Aizzaac Mar 08 '17 at 22:00
  • 1
    So your question translates such as: How to find the position of the minimum in five arrays? This question can further be split down into a) How to find the minimum of an array? and b) How to find the index of a specific element in an array? http://stackoverflow.com/questions/3499026/find-a-minimum-value-in-an-array-of-floats http://stackoverflow.com/questions/176918/finding-the-index-of-an-item-given-a-list-containing-it-in-python Another solution would be to track the minimum while creating these arrays such as starting with infinite min and then replacing if you found a better set of params – Nikolas Rieble Mar 09 '17 at 06:58

0 Answers0