nbsvm.py 文件源码

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

项目:document_classification 作者: scotthlee 项目源码 文件源码
def fit(self, x, y, verbose=True):
        #setting data attributes for the model instance
        X = tfidf_to_counts(x)

        #splitting by target class so we can calculate the log-count ratio
        X_pos = X[np.where(y == 1)]
        X_neg = X[np.where(y == 0)]
        self.r = log_count_ratio(X_pos, X_neg)

        #setting the npos and nneg variables
        n_pos = X_pos.shape[0]
        n_neg = X_neg.shape[0]

        #getting the bais for the MNB model
        self.nb_bias = np.log(np.true_divide(n_pos, n_neg))

    #trains, tests, and assesses the performance of the model
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号