'Learn the idf vector (global term weights)
Parameters
X : sparse matrix, [n_samples, n_features]
a matrix of term/token counts'

def fit(self, X, y=None):

    if (not sp.issparse(X)):
        X = sp.csc_matrix(X)
    if self.use_idf:
        (n_samples, n_features) = X.shape
        df = _document_frequency(X)
        df += int(self.smooth_idf)
        n_samples += int(self.smooth_idf)
        idf = (np.log((float(n_samples) / df)) + 1.0)
        self._idf_diag = sp.spdiags(idf, diags=0, m=n_features, n=n_features, format=u'csr')
    return self
