scikit-learn/scikit-learn

Surprising result in BayesianGaussianMixture

Open

#8 632 ouverte le 22 mars 2017

Voir sur GitHub
 (12 commentaires) (2 réactions) (0 assignés)Python (27 020 forks)batch import
Bughelp wantedmodule:mixture

Métriques du dépôt

Stars
 (66 084 stars)
Métriques de merge PR
 (Merge moyen 10j) (90 PRs mergées en 30 j)

Description

I'm surprised by the results of BayesianGaussianMixture

from sklearn.mixture import BayesianGaussianMixture
from sklearn.datasets import make_blobs
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline

rng = np.random.RandomState(3)
X, y = make_blobs(n_samples=500, centers=10, random_state=rng, cluster_std=[rng.gamma(1.5) for i in range(10)])

fig, axes = plt.subplots(2, 4)
gammas = np.logspace(-5, 5, 4)
for gamma, ax in zip(gammas, axes.T):
    bgmm = BayesianGaussianMixture(n_components=10, weight_concentration_prior=gamma).fit(X)
    ax[0].scatter(X[:, 0], X[:, 1], s=5, alpha=.6, c=plt.cm.Vega10(bgmm.predict(X)))
    ax[0].set_title("gamma={:.2f}".format(gamma))
    ax[1].bar(range(10), bgmm.weights_)

image

I'm changing gamma pretty drastically but the distribution of weights doesn't seem to change. Is that expected?

Guide contributeur