'Learn model for the data X with variational Bayes method.
When `learning_method` is \'online\', use mini-batch update.
Otherwise, use batch update.
Parameters
X : array-like or sparse matrix, shape=(n_samples, n_features)
Document word matrix.
Returns
self'

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

    self._check_params()
    X = self._check_non_neg_array(X, 'LatentDirichletAllocation.fit')
    (n_samples, n_features) = X.shape
    max_iter = self.max_iter
    evaluate_every = self.evaluate_every
    learning_method = self.learning_method
    if (learning_method is None):
        warnings.warn("The    default    value    for    'learning_method'    will    be    changed    from    'online'    to    'batch'    in    the    release    0.20.    This    warning    was    introduced    in    0.18.", DeprecationWarning)
        learning_method = 'online'
    batch_size = self.batch_size
    self._init_latent_vars(n_features)
    last_bound = None
    n_jobs = _get_n_jobs(self.n_jobs)
    with Parallel(n_jobs=n_jobs, verbose=max(0, (self.verbose - 1))) as parallel:
        for i in xrange(max_iter):
            if (learning_method == 'online'):
                for idx_slice in gen_batches(n_samples, batch_size):
                    self._em_step(X[idx_slice, :], total_samples=n_samples, batch_update=False, parallel=parallel)
            else:
                self._em_step(X, total_samples=n_samples, batch_update=True, parallel=parallel)
            if ((evaluate_every > 0) and (((i + 1) % evaluate_every) == 0)):
                (doc_topics_distr, _) = self._e_step(X, cal_sstats=False, random_init=False, parallel=parallel)
                bound = self._perplexity_precomp_distr(X, doc_topics_distr, sub_sampling=False)
                if self.verbose:
                    print ('iteration:    %d    of    max_iter:    %d,    perplexity:    %.4f' % ((i + 1), max_iter, bound))
                if (last_bound and (abs((last_bound - bound)) < self.perp_tol)):
                    break
                last_bound = bound
            elif self.verbose:
                print ('iteration:    %d    of    max_iter:    %d' % ((i + 1), max_iter))
            self.n_iter_ += 1
    (doc_topics_distr, _) = self._e_step(X, cal_sstats=False, random_init=False, parallel=parallel)
    self.bound_ = self._perplexity_precomp_distr(X, doc_topics_distr, sub_sampling=False)
    return self
