# 2 Most probable labels with Gaussian Mixture Model Clustering

I want to get the two most probable labels for each sample in my X.

A little context: I am working on a clustering project where I have 1.6M samples that have to be clustered into 12 clusters. First, I did KMeans and it works fine, except that KMeans is a hard clusterer model so it only gives one exclusive label per sample. For my project, I need to get not one but the top 2 most probable labels, which is why I changed to Gaussian Mixture Model.

I was thinking of doing this by looking through the array of probabilities for each component per sample and find the 2 highest values and this way, assign the labels.

So two questions:

1. How can I find the two highest values in an array and their location?

or.. if there is an easier way:

1. How can I assign the top two labels to each sample?

You can use the predict_proba method along with numpy argsort

predict_proba(X)
Predict posterior probability of each component given the data.

import numpy as np, pandas as pd
from sklearn.mixture import GaussianMixture