SelectKBest(chi2,k=5)。fit(x\u train,y\u train)如何计算得分?

2024-09-28 01:31:32 发布

您现在位置:Python中文网/ 问答频道 /正文

输入数据:

id    diagnosis    Invoice No    Test Name
111      M              2            2
112      B              6            5
113      M              4            6

代码:

#2) Univariate feature selection and random forest classification
from sklearn.feature_selection import SelectKBest
from sklearn.feature_selection import chi2
# find best scored features

select_feature = SelectKBest(chi2, k=1).fit(x_train, y_train)

print('Score list:', select_feature.scores_)
print('Feature list:', x_train.columns)
p.append(x_train.columns.values.tolist())

输出:

{'Test Name': 0.09090909090909091}

现在我的问题是如何计算得分?你知道吗


Tags: columns数据namefromtestimporttrainsklearn

热门问题