原理: 卡方计算(例子) ”无数据“ #如何使用卡方检测相关度 from sklearn.feature_selection import SelectKBest,chi2 import pandas as pd file='data.csv' df=pd.read_csv(file,encoding='gbk') #数据本身 X=df.iloc[:,:-1].values #iloc取下标位置 y=df.iloc[:,-1].values new_data=SelectKBest(chi2,k=2).fit_transform(X,y) print()