def featuresByChiSq(features,labels,nFeature=5000): chi2_model = SelectKBest(chi2,k=nFeature) dtm = chi2_model.fit_transform(features,labels) return dtm,chi2_model