Speed up the learning time of EM for large dataset (#1529)
Speed up the learning time of EM for large dataset (#1529)

* Speed up the learning time of EM for large dataset

The `_compute_weights()` method of ExpectationMaximization will
traverse all unique data in the dataset use `for` loop.

if the count of unique data is large, the `_compute_weights()` method
will take too much time in `for` loop.

I make a try to use `joblib.Parallel` for paralleling, and find that it
saves 70% to 80% time on my dataset with 9994 unique records and
10 columns. The number of latent variables in my test are 3.

* use black to format the code

* Fix the wrong offset pass to parallel

* Take n_jobs as a argument of _compute_weights

Take `n_jobs` as a argument of `compute_weights()` to control the number
of paralleling processes. It uses the `n_jobs` of `get_parameters()`.
Suggest to use `n_jobs=1` when dataset
size less than 1000.

* Add batch_size as a argument of get_parameters

Add `batch_size` as a argument of `get_parameters()`, and pass it to
`_compute_weights()` to control  number of data used to compute weights
in a batch.
ankurankan/pgmpy,pgmpy/pgmpy,pgmpy/pgmpy,ankurankan/pgmpy