我试图从一个大数据帧中找出最好的特性。我能够获取压缩的数据帧值,但无法获取所选功能的名称。 下面是我的代码:
print('Shape of the bigramdf before feature selection:',bigram_df.shape)
if not os.path.isfile('smalldata/bigram_feather_top_100.feather'):
SelectKBest(score_func=chi2,k=100).fit(bigram_df.iloc[:,:-1],df['class'])
cols=SelectKBest.get_support(indices=False) # I am getting error here
selc_k_best_byte_bigram=bigram_df[:,cols]
selc_k_best_byte_bigram['id']=bigram_df['id']
selc_k_best_byte_bigram.to_feather('smalldata/bigram_feather_top_100.feather')
print('Shape of the bigramdf before feature selection:',selc_k_best_byte_bigram.shape)
else:
selc_k_best_byte_bigram=pd.read_feather('smalldata/bigram_feather_top_100.feather')
我得到以下错误:
TypeError: get_support() missing 1 required positional argument: 'self'
有人能帮我找出为什么我会有这个打字错误吗
我想你需要在一个变量中初始化这个类,然后调用。获取支持。因此,尝试替换:
与
相关问题 更多 >
编程相关推荐