我面临这个错误;; AttributeError: 模块 'numpy' 没有属性 'corroef'

问题描述

我尝试使用相关性来提取特征,但我遇到了这个问题: 请帮帮我,我该如何解决?

AttributeError: 模块 'numpy' 没有属性 'corroef'

这是我关联功能的代码::

    cor_list = []
    feature_name = X_train[0]
    print(feature_name)
    #calculate the correlation with y for each feature
    for i in feature_name:
        cor = np.corroef(X_train[i],y_train)[0,1]
        cor_list.append(cor)
     #replace NaN with 0
    cor_list = [0 if np.isnan(i) else i for i in cor_list]
    #feature_name
    cor_feature = X_train.iloc[:np.argsort(np.abs(cor_list))[-num_feats:]].columns.tolist()
    return cor_feature ```


解决方法

你拼错了 corrcoef... 这是语法:

numpy.corrcoef(x,y=None,rowvar=True,bias=<no value>,ddof=<no value>,*,dtype=None)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...