manage.py 文件源码

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

项目:sentiment-analysis 作者: kasheemlew 项目源码 文件源码
def get_emotion():
    print "Calculating thetas..."
    get_theta()
    print "Done!"
    comments = Comment.query.filter_by(emotion=-1).all()
    for comment in comments:
        x = [1, float(comment.pos_count), float(comment.neg_count)]
        hypothesis = 0
        feature_sum = 0
        for i in range(3):
            feature_sum += theta[i]*x[i]
        hypothesis = 1 / (1+math.e**-(feature_sum))
        if 0 < hypothesis < 0.4:
            comment.analysis_score = 0
        elif 0.4 <= hypothesis < 0.6:
            comment.analysis_score = 0.5
        elif 0.6 <= hypothesis < 1:
            comment.analysis_score = 1
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号