In der vorherigen scikit-learn Version (0.1.17) habe ich den folgenden Code verwendet, um automatisch die besten Gaußschen Mischungsmodelle zu bestimmen und Hyperparameter zu optimieren , Kovarianztyp, bic) für unüberwachtes Clustering.Alt (sklearn 0.17) GMM, DPGM, VBGMM vs neu (sklearn 0.18) GaussianMixture und BayesianGaussianMixture
# Gaussian Mixture Model
try:
# Determine the most suitable covariance_type
lowest_bic = np.infty
bic = []
cv_types = ['spherical', 'tied', 'diag', 'full']
for cv_type in cv_types:
# Fit a mixture of Gaussians with EM
gmm = mixture.GMM(n_components=NUMBER_OF_CLUSTERS, covariance_type=cv_type)
gmm.fit(transformed_features)
bic.append(gmm.bic(transformed_features))
if bic[-1] < lowest_bic:
lowest_bic = bic[-1]
best_gmm = gmm
best_covariance_type = cv_type
gmm = best_gmm
except Exception, e:
print 'Error with GMM estimator. Error: %s' % e
# Dirichlet Process Gaussian Mixture Model
try:
# Determine the most suitable alpha parameter
alpha = 2/math.log(len(transformed_features))
# Determine the most suitable covariance_type
lowest_bic = np.infty
bic = []
cv_types = ['spherical', 'tied', 'diag', 'full']
for cv_type in cv_types:
# Fit a mixture of Gaussians with EM
dpgmm = mixture.DPGMM(n_components=NUMBER_OF_CLUSTERS, covariance_type=cv_type, alpha = alpha)
dpgmm.fit(transformed_features)
bic.append(dpgmm.bic(transformed_features))
if bic[-1] < lowest_bic:
lowest_bic = bic[-1]
best_dpgmm = dpgmm
best_covariance_type = cv_type
dpgmm = best_dpgmm
except Exception, e:
print 'Error with DPGMM estimator. Error: %s' % e
# Variational Inference for Gaussian Mixture Model
try:
# Determine the most suitable alpha parameter
alpha = 2/math.log(len(transformed_features))
# Determine the most suitable covariance_type
lowest_bic = np.infty
bic = []
cv_types = ['spherical', 'tied', 'diag', 'full']
for cv_type in cv_types:
# Fit a mixture of Gaussians with EM
vbgmm = mixture.VBGMM(n_components=NUMBER_OF_CLUSTERS, covariance_type=cv_type, alpha = alpha)
vbgmm.fit(transformed_features)
bic.append(vbgmm.bic(transformed_features))
if bic[-1] < lowest_bic:
lowest_bic = bic[-1]
best_vbgmm = vbgmm
best_covariance_type = cv_type
vbgmm = best_vbgmm
except Exception, e:
print 'Error with VBGMM estimator. Error: %s' % e
Wie gleiche oder ein ähnliches Verhalten mit neuen Gaussian Mixture/Bayesian Gaussian Mixture Modelle in Scikit-Learn 0.1.18 eingeführt zu erreichen?
Laut scikit-learn-Dokumenten gibt es keinen "alpha" -Parameter mehr, stattdessen gibt es den Parameter "weight_concentration_prior". Sind diese gleich oder nicht? http://scikit-learn.org/stable/modules/generated/sklearn.mixture.BayesianGaussianMixture.html#sklearn.mixture.BayesianGaussianMixture
weight_concentration_prior: float | Keine, optional. Die Dirichlet-Konzentration jeder Komponente auf die Gewichtsverteilung (Dirichlet). Die höhere Konzentration bringt mehr Masse in das Zentrum und führt dazu, dass mehr Komponenten aktiv sind, während ein niedrigerer Konzentrationsparameter zu mehr Masse am Rand von führen wird. Der Wert des Parameters muss größer als 0 sein. Wenn es None ist, wird er auf 1/n_components gesetzt.
http://scikit-learn.org/0.17/modules/generated/sklearn.mixture.VBGMM.html
alpha: float, default 1: Reelle Zahl der Konzentrationsparameter der Dirichlet Verteilung darstellt. Intuitiv, je höher der Wert von Alpha wahrscheinlicher ist, wird die Variationsmischung des Gauß-Modells alle Komponenten verwenden, die es kann.
Wenn diese beiden Parameter (Alpha und weight_concentration_prior) gleich sind, bedeutet es, dass die Formel alpha = 2/Math.log (len (transformed_features)) aplies noch für die weight_concentration_prior = 2/Math.log (len (transformierte_features))?
Es scheint, dass es keinen "Alpha" -Parameter mehr gibt. Stattdessen gibt es den Parameter "weight_concentration_prior". Ich bin mir nicht sicher, ob diese beiden tatsächlich gleich sind oder nicht? – zlatko
Es scheint auch, dass während in GaussianMixture Klasse BIC und AIC immer noch vorhanden sind (wie @ogrisel hingewiesen), gibt es keine BIC und AIC in BayessianGaussianMixture. Warum? – zlatko
Der neue weight_concentration_prior ist das Äquivalent des alten Alphas neben der Tatsache, dass die veraltete Implementierung mehrere Bugs hatte, die neue Implementierung scheint soweit ich weiß. – ogrisel