Skip to content
Advertisement

pipeline for RandomOversampler, RandomForestClassifier & GridSearchCV

I am working on a binary text classification problem. As the classes are highly imbalanced, I am using sampling techniques like RandomOversampler(). Then for classification I would use RandomForestClassifier() whose parameters need to be tuned using GridSearchCV().

I am trying to create a pipeline to do these in order but failed so far. It throws invalid parameters.

JavaScript

Advertisement

Answer

The parameters you defined in the params is for RandomForestClassifier, but in the gridSearchCV, you are not passing a RandomForestClassifier object.

You are passing a pipeline object, for which you have to rename the parameters to access the internal RandomForestClassifier object.

Change them to:

JavaScript

And it will work.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement