<｜begin▁of▁sentence｜>### Instruction:
Suppose we have generated a synthetic dataset with 300 samples that form three blobs. We want to group these observations into clusters, but we are uncertain about the number of clusters that best represent our data. How can we use the AutoGMMCluster class from graspologic to automatically determine the number of clusters and fit a Gaussian Mixture Model to our data?
### Response:
import numpy as np
from graspologic.cluster import AutoGMMCluster
from sklearn.datasets import make_blobs

# Generate synthetic data
n_samples = 300
centers = [(-5, -5), (0, 0), (5, 5)]
X, y_true = make_blobs(n_samples=n_samples, centers=centers, cluster_std=1.0, random_state=42)

# Fit the AutoGMMCluster
gmm_cluster = AutoGMMCluster(min_components=2, max_components=4, affinity='euclidean', linkage='ward')
gmm_results = gmm_cluster.fit(X)

# Predict the cluster labels
labels = gmm_cluster.predict(X)

# Print best model based on BIC
print(f'Best model - number of clusters: {gmm_cluster.n_components_}')
<|EOT|>
