{"id":18770125,"url":"https://github.com/andreacasalino/gaussian-mixture-model","last_synced_at":"2025-04-13T07:31:57.805Z","repository":{"id":37026064,"uuid":"191435687","full_name":"andreacasalino/Gaussian-Mixture-Model","owner":"andreacasalino","description":"C++ library handling Gaussian Mixure Models","archived":false,"fork":false,"pushed_at":"2022-06-19T08:04:15.000Z","size":1850,"stargazers_count":10,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2023-03-04T01:29:40.347Z","etag":null,"topics":["cpp","eigen","expectation-maximization","gaussian","gaussian-mixture-models","training"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andreacasalino.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-06-11T19:19:23.000Z","updated_at":"2023-01-17T15:53:07.000Z","dependencies_parsed_at":"2022-08-19T01:40:09.476Z","dependency_job_id":null,"html_url":"https://github.com/andreacasalino/Gaussian-Mixture-Model","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreacasalino%2FGaussian-Mixture-Model","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreacasalino%2FGaussian-Mixture-Model/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreacasalino%2FGaussian-Mixture-Model/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreacasalino%2FGaussian-Mixture-Model/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andreacasalino","download_url":"https://codeload.github.com/andreacasalino/Gaussian-Mixture-Model/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223573916,"owners_count":17167400,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp","eigen","expectation-maximization","gaussian","gaussian-mixture-models","training"],"created_at":"2024-11-07T19:18:14.727Z","updated_at":"2024-11-07T19:18:15.439Z","avatar_url":"https://github.com/andreacasalino.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"![binaries_compilation](https://github.com/andreacasalino/Gaussian-Mixture-Model/actions/workflows/installArtifacts.yml/badge.svg)\n![binaries_compilation](https://github.com/andreacasalino/Gaussian-Mixture-Model/actions/workflows/runTests.yml/badge.svg)\n\nThis libary contains the functionalities required to train and handle **Gaussian Mixture Models**, aka **GMM**.\nIf you believe to be not really familiar with this object, have a look at ./doc/Gaussian_Mixture_Model.pdf.\n\nThe construction of a **GMM** can be done by explicitly define the clusters:\n```cpp\n#include \u003cGaussianMixtureModel/GaussianMixtureModel.h\u003e\n\n// A gaussian mixture model (gmm) is made of clusters,\n// which are basically gaussian distribution with an associated weight.\n//\n// You can create a gmm by firstly defining the clusters.\nstd::vector\u003cgauss::gmm::Cluster\u003e clusters;\n// add the first cluster\nEigen::VectorXd cluster_mean = ; // fill the mean values\nEigen::MatrixXd cluster_covariance = ; // fill the covariance values\ndouble cluster_weight = 0.1;\nstd::unique_ptr\u003cgauss::GaussianDistribution\u003e cluster_distributon = std::make_unique\u003cgauss::GaussianDistribution\u003e(cluster_mean, cluster_covariance);\nclusters.push_back(gauss::gmm::Cluster{ cluster_weight, std::move(cluster_distributon) });\n// similarly, add the second and all the others cluster\nclusters.push_back(...);\n// now that the clusters are defined, build the gmm\ngauss::gmm::GaussianMixtureModel gmm_model(clusters);\n```\n\nOr by traininig using the [**Expectation Maximization**](https://stephens999.github.io/fiveMinuteStats/intro_to_em.html) algorithm:\n```cpp\n// the samples from which the gmm should be deduced\nstd::vector\u003cEigen::VectorXd\u003e samples;\n// apply expectation maximization (EM) to compute the set of clusters that\n// best fit the given samples.\n// The number of expected clusters should be specified\nconst std::size_t clusters_size = 4;\nstd::vector\u003cgauss::gmm::Cluster\u003e clusters = gauss::gmm::ExpectationMaximization(samples, clusters_size);\n// use the computed clusters to build a gmm\ngauss::gmm::GaussianMixtureModel gmm_model(clusters);\n```\nIt is also possible to specify the initial clusters from which the iterations of the **Expectation Maximization** start. \nOtherwise, when non specifying anything, the [**k-means**](https://en.wikipedia.org/wiki/K-means_clustering) is internally called to create the starting clusters.\n**k-means** is also exposed as a callable stand-alone algorithm.\n\nYou can also draw samples from an already built **GMM**:\n```cpp\nstd::vector\u003cEigen::VectorXd\u003e samples = gmm_model.drawSamples(5000)\n```\n\nAnd generate a completely random **GMM**:\n```cpp\n#include \u003cGaussianMixtureModel/GaussianMixtureModelFactory.h\u003e\n\nconst std::size_t space_size = 4;\nconst std::size_t clusters_size = 3;\ngauss::gmm::GaussianMixtureModelFactory model_factory(space_size, clusters_size); // this factory will generate model living in R^4, adopting 3 random clusters\nstd::unique_ptr\u003cgauss::gmm::GaussianMixtureModel\u003e random_gmm_model = model_factory.makeRandomModel();\n```\n\nThis package is completely **cross-platform**: use [CMake](https://cmake.org) to configure the project containig the libary and some samples.\n\nThis library uses [**Eigen**](https://gitlab.com/libeigen/eigen) as internal linear algebra engine. \n**Eigen** is by default [fetched](https://cmake.org/cmake/help/latest/module/FetchContent.html) from the official gitlab repo by **CMake** and made available.\nHowever, if you already have installed **Eigen** on your machine you can also decide to use that local version, by [setting](https://www.youtube.com/watch?v=LxHV-KNEG3k\u0026t=1s) the **CMake** option **EIGEN_INSTALL_FOLDER** equal to the root folder storing the local **Eigen** you want to use.\n\nIf you have found this library useful, take the time to leave a star ;)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandreacasalino%2Fgaussian-mixture-model","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandreacasalino%2Fgaussian-mixture-model","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandreacasalino%2Fgaussian-mixture-model/lists"}