简体   繁体   English

TypeError: __init__() takes 2 positional arguments but 3 were given - 使用递归特征消除的特征提取

[英]TypeError: __init__() takes 2 positional arguments but 3 were given - feature extraction using recursive feature elimination

My code is giving the error as TypeError: __init__() takes 2 positional arguments but 3 were given.我的代码给出错误TypeError: __init__() takes 2 positional arguments but 3 were given. Tried searching for an extra argument but couldn't get one.试图寻找一个额外的论点,但找不到。

Tried previously answered questions but didn't get any proper solution.尝试过以前回答的问题,但没有得到任何适当的解决方案。 My code is as follows:我的代码如下:

features = ['EMB_CD3', 'EMB_CD45R0', 'EMB_LFA1', 'EMB_Perforin', 'EMB_Mac', 'EMB_HLA1', 'EMB_CD54', 
            'EMB_VCAM', 'Virus:1=Cox,4=B19V,6=HHV6,5=EBV,2=ADV(including double infections)', 'Viral_load_B19V-VP1_mRNA',
            'Viral_load_DNA_B19V','Virus_EBV', 'Virus_HHV-6', 'B19V-Typ1']
df_new = df[features].copy()
#KNN Imputer for missing values
imputer = KNNImputer(n_neighbors=3)
imputed = imputer.fit_transform(df_new)
df_imputed = pd.DataFrame(imputed, columns=df_new.columns)

X = df_imputed
Y = df['target'].astype(int)
#%% feature extraction using Recursive Feature Elimination
model = LogisticRegression(solver='lbfgs')
rfe = RFE(model, 10)
fit = rfe.fit(X, Y)
print("Num Features: %s" % (fit.n_features_))
print("Selected Features: %s" % (fit.support_))
print("Feature Ranking: %s" % (fit.ranking_))

compiler gives runtime error as follows:编译器给出如下运行时错误:

runfile('C:/Users/drash/OneDrive/Desktop/Howto Health/preprocessing 1.py', wdir='C:/Users/drash/OneDrive/Desktop/Howto Health')
Traceback (most recent call last):
File "C:\Users\drash\OneDrive\Desktop\Howto Health\preprocessing 1.py", line 60, in <module>
    rfe = RFE(model, 10)

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

RFE documentation and constructor information is here . RFE 文档和构造函数信息位于此处 Instead of writing RFE(model, 10) , try RFE(model, n_features_to_select=10)不要写RFE(model, 10) ,试试RFE(model, n_features_to_select=10)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 类型错误:__init__() 需要 3 个位置参数,但给出了 4 个 - TypeError: __init__() takes 3 positional arguments but 4 were given TypeError:__init __()接受4个位置参数,但给出了5个 - TypeError: __init__() takes 4 positional arguments but 5 were given TypeError: __init__() 接受 2 个位置参数,但在 RFE 中给出了 3 个 - TypeError: __init__() takes 2 positional arguments but 3 were given in RFE 继承 TypeError: __init__() 接受 1 到 2 个位置参数,但给出了 8 个 - inheritance TypeError: __init__() takes from 1 to 2 positional arguments but 8 were given TypeError: __init__() 需要 2 个位置 arguments 但在 Selenium POP 中给出了 3 个 - TypeError: __init__() takes 2 positional arguments but 3 were given in Selenium POP Tkinter | TypeError: __init__() takes from 1 to 2 positional arguments but 3 were given - Tkinter | TypeError: __init__() takes from 1 to 2 positional arguments but 3 were given Python: TypeError: __init__() takes from 1 to 2 positional arguments but 3 were given - Python : TypeError: __init__() takes from 1 to 2 positional arguments but 3 were given python super:TypeError:__init __()接受2个位置参数,但给出了3个 - python super :TypeError: __init__() takes 2 positional arguments but 3 were given Money 和 TypeError:__init__() 需要 1 到 2 个位置参数,但给出了 3 个 - Money and TypeError: __init__() takes from 1 to 2 positional arguments but 3 were given 类型错误:__init__() 需要 2 个位置参数,但给出了 4 个 - TypeError: __init__() takes 2 positional arguments but 4 were given
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM