analysis_utilities.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:oss-github-analysis-project 作者: itu-oss-project-team 项目源码 文件源码
def export_best_feature_names(self, df, labels, out_folder_path, k):
        columns, repos, observations = self.decompose_df(df)
        feature_scores = SelectKBest(chi2, k=k).fit(observations, labels).scores_
        feature_scores = np.nan_to_num(feature_scores)
        k_best_features = np.argpartition(feature_scores.ravel(), (-1) * k)[(-1) * k:]
        k_best_feature_names = columns[k_best_features]

        out_file_path = os.path.join(out_folder_path, "feature_selection.txt")
        with open(out_file_path, "w") as output_file:
            for feature_name in k_best_feature_names:
                output_file.write(feature_name + "\n")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号