Bernoulli Mixture Models with flexmix

Mixture Models in R

Victor Medina

Researcher at The University of Edinburgh

The problem

Mixture Models in R

The dataset

digits_sample <- as.matrix(digits)
dim(digits_sample)
320 256
show_digit(digits_sample[320,])

Mixture Models in R

Fit Bernoulli mixture models

bernoulli_mix_model <- flexmix(digits_sample~1,
              k=2,
              model=FLXMCmvbinary(),
              control = list(tolerance = 1e-15, iter.max = 1000))
  • digits_sample is a matrix
  • FLXMCmvbinary() specifies the Bernoulli distribution
Mixture Models in R

The proportions

prior(bernoulli_mix_model)
0.503125 0.496875
Mixture Models in R

parameters() function

param_comp1 <- parameters(bernoulli_mix_model, component = 1)
param_comp2 <- parameters(bernoulli_mix_model, component = 2)
dim(param_comp1)
256   1
head(param_comp1, 4)
             Comp.1
center.V1 0.3291926
center.V2 0.5093168
center.V3 0.6645963
center.V4 0.7639751
Mixture Models in R

Visualize the component 1

show_digit(param_comp1)

Mixture Models in R

Visualize the component 2

show_digit(param_comp2)

Mixture Models in R

Let's practice!

Mixture Models in R

Preparing Video For Download...