Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does GMM have the option to get the cluster probability? #372

Open
rickbeeloo opened this issue Jan 31, 2025 · 1 comment
Open

Does GMM have the option to get the cluster probability? #372

rickbeeloo opened this issue Jan 31, 2025 · 1 comment
Labels
good first issue Good for newcomers

Comments

@rickbeeloo
Copy link

Hey!

After doing the fit:

// We fit the model from the dataset setting some options
    let gmm = GaussianMixtureModel::params(n_clusters)
                .n_runs(10)
                .tolerance(1e-4)
                .with_rng(rng)
                .fit(&dataset).expect("GMM fitting");

    // Then we can get dataset membership information, targets contain **cluster indexes**
    // corresponding to the cluster infos in the list of GMM means and covariances
    let blobs_dataset = gmm.predict(dataset);

Can I get the probability of it belonging to one of the clusters? It will assign it to the cluster with the highest probability (I assume) however, I want to only assign if the probability is higher than a specific threshold.

I'm not familiar with linfa at all, so perhaps there is a standard way of doing this.

Thanks for building all this!

@relf
Copy link
Member

relf commented Feb 1, 2025

Hi. Unfortunatly, at the moment, this information is not made available.

The good news is that the implementation is rather straightforward. If I understand correctly you need predict_proba() as implemented in scikit-learn. As linfa GMM implementation is a direct port of the scikit-learn one, the code is pretty similar and the method can be easily ported. Let me know if you want to open a PR on this.

@relf relf added the good first issue Good for newcomers label Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants