# \[ANN\] ExpectationMaximization.jl - Generic EM algo to fit\_mle MixtureModels

**URL:** https://discourse.julialang.org/t/ann-expectationmaximization-jl-generic-em-algo-to-fit-mle-mixturemodels/96513
**Category:** Package Announcements
**Tags:** package, announcements, distributions, mixturemodel
**Created:** [March 23, 2023, 2:56pm UTC](https://discourse.julialang.org/t/ann-expectationmaximization-jl-generic-em-algo-to-fit-mle-mixturemodels/96513 "2023-03-23T14:56:58Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![dmetivie](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dmetivie/32/6926_2.png) [@dmetivie](https://discourse.julialang.org/u/dmetivie)
#### Post date: [March 23, 2023, 2:56pm UTC](https://discourse.julialang.org/t/ann-expectationmaximization-jl-generic-em-algo-to-fit-mle-mixturemodels/96513/1 "2023-03-23T14:56:58Z")

</div>

I am happy to announce the package [ExpectationMaximization.jl](https://github.com/dmetivie/ExpectationMaximization.jl).

The purpose is to implement in a very generic “Julia way” EM algorithm to find the maximum likelihood estimator (`fit_mle`) for `MixtureModels` i.e. mixture of distributions.

I basically just had to write the pseudocode of the algorithm and rely on the `Distributions.jl` package that implements the `fit_mle(::Type{Distributions}, y[, w])` estimator I need.

The result is a package able to fit all mixture of distributions covered by `Distributions.jl`. This is different from other R, Python packages where the distributions available are the one hand-coded by the package manager (“Top-Down” approach).

I also added a few `fit_mle` methods (like for product distributions), which I plan to add directly in `Distributions.jl` soon.

For example, you can do:

- Mixture of Univariate distributions (all crazy combination you want)

- Mixture of Multivariate distributions (famous [Gaussian Mixtures](https://dmetivie.github.io/ExpectationMaximization.jl/dev/examples/#Old-Faithful-Geyser-Data-(Multivariate-Normal)), but also [Bernoulli mixture for MNIST](https://dmetivie.github.io/ExpectationMaximization.jl/dev/examples/#MNIST-dataset:-Bernoulli-Mixture))

- Mixture of mixtures (not seen that anywhere else)

- More? (We just [discussed](https://github.com/dmetivie/ExpectationMaximization.jl/issues/8) [`Copula.jl`](https://github.com/lrnv/Copulas.jl) + `ExpectationMaximization.jl`)

I did [benchmark](https://dmetivie.github.io/ExpectationMaximization.jl/dev/benchmarks/), it is Julia fast, meaning that it beats other Python (like Scikit-Learn), R existing packages (most are specialized for Normal distribution) with my basic Julia knowledge.

(However, I am always happy to speed up).

I did [docs](https://dmetivie.github.io/ExpectationMaximization.jl/dev/) with [examples](https://dmetivie.github.io/ExpectationMaximization.jl/dev/examples/).

The last point is the that I use a slightly different convention than the `Distribution.jl` package, as I use the instance version of `fit_mle(D::Distribution, y)` and not `fit_mle(Type{D}, y)`. This is discussed in several places, like [in the docs](https://dmetivie.github.io/ExpectationMaximization.jl/dev/fit_mle/) or in this [PR#1670](https://github.com/JuliaStats/Distributions.jl/pull/1670).

---

<div class="post-metadata">

### Author: ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)
#### Post date: [March 23, 2023, 3:06pm UTC](https://discourse.julialang.org/t/ann-expectationmaximization-jl-generic-em-algo-to-fit-mle-mixturemodels/96513/2 "2023-03-23T15:06:28Z")

</div>

Very nice addition to the stats toolkit! 🎉 :julia:
