feature_weighting.py 文件源码

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

项目:FreeDiscovery 作者: FreeDiscovery 项目源码 文件源码
def transform(self, X, y=None):
        """Apply document term weighting and normalization on text features

        Parameters
        ----------
        X : sparse matrix, [n_samples, n_features]
            a matrix of term/token counts
        copy : boolean, default True
            Whether to copy X and operate on the copy or perform in-place
            operations.
        """
        X = check_array(X, ['csr'], copy=self.copy)
        check_is_fitted(self, 'dl_', 'vector is not fitted')
        if X.shape[1] != self._n_features:
            raise ValueError(('Model fitted with n_features={} '
                              'but X.shape={}')
                             .format(self._n_features, X.shape))

        if self.df_ is not None:
            df_n_samples = len(self.dl_)
        else:
            df_n_samples = None

        return _smart_tfidf(X, self.weighting, self.df_,
                            df_n_samples,
                            norm_alpha=self.norm_alpha,
                            norm_pivot=self.norm_pivot)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号