Vadim
Vadim

Reputation: 81

__init__() takes 2 positional arguments but 3 were given

Help me please. Install scikit-learn not working

data_final_vars=data_final.columns.values.tolist()
y=['y']
X=[i for i in data_final_vars if i not in y]
from sklearn.feature_selection import RFE
from sklearn.linear_model import LogisticRegression
logreg = LogisticRegression()
rfe = RFE(logreg, 20)
rfe = rfe.fit(os_data_X, os_data_y.values.ravel())
print(rfe.support_)
print(rfe.ranking_)

Error in line 7: TypeError: init() takes 2 positional arguments but 3 were given

Upvotes: 7

Views: 18126

Answers (2)

Rosa Aghdam
Rosa Aghdam

Reputation: 131

To use RFE, first the class is configured with the chosen algorithm specified via the “estimator” argument and the number of features to select via the “n_features_to_select” argument.

Try

rfe = RFE(estimator=LogisticRegression(), n_features_to_select=20)

Upvotes: 7

TheKindStranger
TheKindStranger

Reputation: 187

Try specifying that you're overriding a default parameter:

rfe = RFE(logreg, step = 20)

Upvotes: 17

Related Questions