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

1.9k views Asked by At
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
2

There are 2 answers

1
Mahamudul Hasan On

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)

0
vishakha singh On

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)