top_terms.py 文件源码

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

项目:xam 作者: MaxHalford 项目源码 文件源码
def fit(self, X, y=None, **fit_params):

        # scikit-learn checks
        X, y = check_X_y(X, y)

        n_terms = min(self.n_terms, X.shape[1])

        # Get a list of unique labels from y
        labels = np.unique(y)

        # Determine the n top terms per class
        self.top_terms_per_class_ = {
            c: set(np.argpartition(np.sum(X[y == c], axis=0), -n_terms)[-n_terms:])
            for c in labels
        }

        # Return the classifier
        return self
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号