Nymph
Nymph

Reputation: 146

Cannot assign class_weight to RandomForestClassifier in Scikit Learn

i just started some time ago to use the scikit learn package to implement Random Forests on my data set. I am trying to make a model based on multiple classes, and tried to implement the RandomForestClassifier. However, i think i have some imbalance and i want to use the class_weight="auto" parameter:

RFC = RandomForestClassifier(n_estimators = int(trees),class_weight="auto").fit(X_train, y_train)

However, when i try to run it, i get

__init__() got an unexpected keyword argument 'class_weight'

I tried checking at other questions, since i thought i didn't use the correct notation, but they all seem to reference class_weight="auto" in that way.

Note: The RF works without the class_weight parameter. I just want to try to improve my results because i think the data is imbalanced.

Thanks (if i did something wrong with formatting or the question, i will edit it, first question here)

Upvotes: 1

Views: 2053

Answers (1)

Nymph
Nymph

Reputation: 146

I made the mistake of checking the wrong version list. I run in ipython, and while i did update it on the server, it didn't go through in the ipython enviroment, and when i checked it with conda, it was all the times without the ipython enviroment on. I updated it and it worked, thanks. Sorry, but thanks for looking into it.

Upvotes: 1

Related Questions