Skip to content
Advertisement

How to plot density estimation contours of a model with 20 features?

I am following this sample to do density estimation for the Bayesian Gaussian mixture model below:

JavaScript

in which data (as a dataframe) includes 20 columns of numeric data.

I can simply plot the model for two features of bgmm by

JavaScript

But, how can I plot all the clusters in the form of density contours?

Advertisement

Answer

I believe you need to get your data into one big two-column array before fitting, so define a new X_train that combines all ten pairs of columns into one big pair of columns.

First, convert data into an array:

JavaScript

And then reshape into two columns:

JavaScript

and then call the mixture.fit method with that instead of data. Then just continue following the sample, using X_train as they do (and of course use bgmm instead of clf).

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement