def pearson_between_feature_class(X,y,threshold):
"""
Computes the Pearson Correlation between each feature and the target class and keeps the higlhy correlated features-class
Keyword arguments:
X -- The feature vectors
y -- The target vector
threshold -- Threshold value used to decide which features to keep (above the threshold)
"""
if verbose:
print '\nPerforming Feature Selection based on the correlation between each feature and class ...'
feature_indexes=[]
for i in xrange(len(X[0])):
if abs(stats.pearsonr(X[:,i],y)[0])>threshold:
feature_indexes+=[i]
if len(feature_indexes)!=0:
return X[:,feature_indexes],feature_indexes #return selected features and original index features
else:
return X,feature_indexes
feature_selection.py 文件源码
python
阅读 60
收藏 0
点赞 0
评论 0
评论列表
文章目录