document_filter.py 文件源码

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

项目:TextCategorization 作者: Y-oHr-N 项目源码 文件源码
def predict(self, ifile, efile, ofile):
        # Load
        columns          = ['documents']
        data             = pd.read_table(ifile, header=None, names=columns)
        documents        = data['documents']

        # Deserialize
        estimator        = pickle.load(open(efile, 'rb'))

        # Predict
        probability      = estimator.predict_proba(documents)
        data['labels']   = estimator.predict(documents)
        data['C1_pr']    = probability[:, 0]
        data['C2_pr']    = probability[:, 1]

        # Save
        columns          = ['labels', 'C1_pr', 'C2_pr', 'documents']
        data.to_csv(
            ofile,
            sep          = '\t',
            columns      = columns,
            index        = False
        )
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号