'Transform a count matrix to a tf or tf-idf representation
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.
Returns
vectors : sparse matrix, [n_samples, n_features]'

def transform(self, X, copy=True):

    if (hasattr(X, u'dtype') and np.issubdtype(X.dtype, np.float)):
        X = sp.csr_matrix(X, copy=copy)
    else:
        X = sp.csr_matrix(X, dtype=np.float64, copy=copy)
    (n_samples, n_features) = X.shape
    if self.sublinear_tf:
        np.log(X.data, X.data)
        X.data += 1
    if self.use_idf:
        check_is_fitted(self, u'_idf_diag', u'idf    vector    is    not    fitted')
        expected_n_features = self._idf_diag.shape[0]
        if (n_features != expected_n_features):
            raise ValueError((u'Input    has    n_features=%d    while    the    model    has    been    trained    with    n_features=%d' % (n_features, expected_n_features)))
        X = (X * self._idf_diag)
    if self.norm:
        X = normalize(X, norm=self.norm, copy=False)
    return X
