ariddell/horizont — pull request #6 by tboggs (2014-08-01 03:15:45+00:00)
Title: Ability to continue model fitting

For sufficiently large vocabularies/corpora, fitting the model can take quite a while. If the model hasn't converged after the chosen number of iterations, one must call `fit` (or `fit_transform`) again with a larger number of iterations, essentially repeating all the previous iterations before continuing to improve the model fit. This change adds a `continue_fitting` method to the `LDA` class that allows one to continue where previous fitting left off. To accomplish this I did the following:

- Split the `_fit` method into `_fit` and `_run_fitting_iterations` (which is called by `_fit`).

- Do not delete the `WS`, `DS`, and `ZS` members after fitting (I added a `delete_temp_vars` method to explicitly do that, if desired).

- Added the `continue_fitting` method (which also calls `_run_fitting_iterations`).

Lastly, I set the `random_state` member in `LDA.__init__`. Take a look at that specifically and let me know if that change would adversely affect anything. I'm not sure what the intent of the following two lines were:

self.random_state = random_state
rng = sklearn.utils.check_random_state(random_state)

When the `random_state` argument is `None`, it appears that the random seed will be initialized twice: once when `rng` is set (in the line above) and again when `self.random_state` is used (since it is still equal to `None` above). Note that my changes still have the seed set twice (though I could easily change that) - the difference is that the `random_state` member is explicitly initialized in the constructor now.