TypeError: __init__() takes 2 positional arguments but 3 were given in RFE

rfe = RFE(lr,15)
rfe.fit(X_train,y_train)

im getting this error

TypeError                                 Traceback (most recent call last)
<ipython-input-65-10f06de816f9> in <module>()
      1 #Cut down number of features to 15 using automated approach
----> 2 rfe = RFE(lr,15)
      3 rfe.fit(X_train,y_train)

TypeError: __init__() takes 2 positional arguments but 3 were given

Upvotes: 0

Views: 2540

Answers (2)

Mahamudul Hasan
Mahamudul Hasan

Reputation: 2823

If you see this document.

RFE(estimator, *, n_features_to_select=None, step=1, verbose=0, importance_getter='auto')

so first attribute is mandatory. rest of the attributes are optional. so you have to mention optional attribute and pass the value. lets say 15 for n_features_to_select .

So, in that case it will be

rfe = RFE(lr,n_features_to_select=15)

Upvotes: 1

vishakha singh
vishakha singh

Reputation: 1

try overriding with giving proper argument names, in your case i believe you want to enter the no. of features hence try this-

rfe = RFE(lr,n_features_to_select=15)

Upvotes: -1

Related Questions