{"id":18770113,"url":"https://github.com/andreacasalino/gaussianprocesses","last_synced_at":"2025-10-24T19:49:45.722Z","repository":{"id":37026082,"uuid":"430490804","full_name":"andreacasalino/GaussianProcesses","owner":"andreacasalino","description":"Modern C++ library handling gaussian processes","archived":false,"fork":false,"pushed_at":"2022-12-07T22:46:20.000Z","size":4099,"stargazers_count":5,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2023-03-04T01:29:40.446Z","etag":null,"topics":["cpp","cpp17","eigen","gaussian","gaussian-distribution","gaussian-process-regression","gaussian-processes","hyperparameter-optimization","hyperparameters","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":"2021-11-21T22:02:14.000Z","updated_at":"2022-12-07T14:33:41.000Z","dependencies_parsed_at":"2022-08-18T17:33:02.725Z","dependency_job_id":null,"html_url":"https://github.com/andreacasalino/GaussianProcesses","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%2FGaussianProcesses","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreacasalino%2FGaussianProcesses/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreacasalino%2FGaussianProcesses/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreacasalino%2FGaussianProcesses/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andreacasalino","download_url":"https://codeload.github.com/andreacasalino/GaussianProcesses/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223573917,"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","cpp17","eigen","gaussian","gaussian-distribution","gaussian-process-regression","gaussian-processes","hyperparameter-optimization","hyperparameters","training"],"created_at":"2024-11-07T19:18:11.272Z","updated_at":"2025-10-24T19:49:40.692Z","avatar_url":"https://github.com/andreacasalino.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"![binaries_compilation](https://github.com/andreacasalino/GaussianProcesses/actions/workflows/installArtifacts.yml/badge.svg)\n![binaries_compilation](https://github.com/andreacasalino/GaussianProcesses/actions/workflows/runTests.yml/badge.svg)\n\n- [What is this library about](#intro)\n- [Usage](#usage)\n- [Features](#features)\n- [CMake support](#cmake-support)\n\n\n![How the predictions with Gaussian Processes look like:](sample.png)\n\n## INTRO\n\nThis library provides a modern **C++** interface that allows you to use and train **Gaussian Processes**, aka **GP**.\nIf you believe to be not really familiar with this kind of models, it is strongly recommended to have a look at these useful tutorials:\n\n- [Gaussian Processes](https://www.youtube.com/watch?v=UBDgSHPxVME\u0026t=794s)\n- [Easy introduction to gaussian process regression](https://www.youtube.com/watch?v=iDzaoEwd0N0)\n\n... and read the documentation [here](doc/Gaussian_Process.pdf). If you have found this library useful, take the time to leave a **star** ;).\n\nScalar and Vectorial multivariate functions can be both approximated using the kind of **GP**s implemented in this package.\n\nThis library uses [**Eigen**](https://gitlab.com/libeigen/eigen) as internal linear algebra engine. Check [here](#cmake-support) for more details.\n\n## USAGE\n\nHaven't already left a **star**? Do it now! ;).\n\nUse this package is straightforward.\n\nFirst of all, you need to define and build a **kernel function**:\n```cpp\n#include \u003cGaussianProcess/GaussianProcess.h\u003e\n#include \u003cGaussianProcess/kernel/SquaredExponential.h\u003e\n\n// for the purpose of this example we will use a simple squared exponential\n  gauss::gp::KernelFunctionPtr kernel_function =\n      std::make_unique\u003cgauss::gp::SquaredExponential\u003e(1.0, 1.0);\n```\n\nYou can now build an empty **GP** passing the previously defined **kernel function**:\n```cpp\n    // The input size of the process will be 3, while the output will be 2, i.e.\n    // this process will be able to approximate a tri-variate vectorial function\n    // made of 2 components.\n    gauss::gp::GaussianProcess gauss_process(std::move(kernel_function),\n                                            3 // input size\n                                            ,\n                                            2 // output size\n    );\n```\n\nAn empty **GP** is useless untill you don't define its training set. Therefore, add some samples to the training set:\n```cpp\n  // fill the training set of the process with samples taken from the (unknown)\n  // function to approximate\n  std::vector\u003cEigen::VectorXd\u003e samples =\n      ...; // each element will be a 5 sized vector, whose first 3 components\n           // represent the values of the input, while the other ones the values\n           // of the output\n  for (const auto \u0026sample_to_add : samples) {\n    gauss_process.getTrainSet().addSample(sample_to_add);\n  }\n```\n\nYou can now use the **GP** to make predictions:\n```cpp\n    // predict the output for an input not contained in the training set\n    Eigen::VectorXd input_to_predict = ...;\n    std::vector\u003cgauss::GaussianDistribution\u003e\n        predicted_output // each component is a scalar guassian distribution\n                         // with a certain mean and covariance matrix\n        = gauss_process.predict(input_to_predict,\n                                gauss::gp::VECTORIAL_PREDICTION_TAG);\n```\nYou can also access the prediction as a unique multivariate distribution (notice that the covariance matrix of such distribution will be in identity matrix multiplied by a certain factor):\n```cpp\n    // access the prediction as a unique multivariate vectorial guassian\n    // distribution\n    gauss::GaussianDistribution predicted_output = gauss_process.predict(\n        input_to_predict, gauss::gp::SINGLE_PREDICTIVE_DISTRIBUTION_TAG);\n```\n\nNot satisfied about the prediciton performance? Maybe the hyperparameters of the **kernel function** are badly set. Try to train the model:\n```cpp\n#include \u003cTrainingTools/iterative/solvers/GradientDescend.h\u003e\n\n  // optimize the hyperparameters through training in order to improve\n  // predicting performance.\n  ::train::GradientDescendFixed\n      gradient_descender; // you can also use another trainer from\n  // TrainingTools, or define your own\n  gauss::gp::train(gauss_process, gradient_descender);\n```\n\n## FEATURES\n\nHaven't already left a **star**? Do it now! ;).\n\nWith respect to similar repositories, this library allows you to:\n- dynamically add new samples to the training set of a **gaussian process** without having to define it once for all\n- access the **covariance kernel matrix** as well as its decomposition and inverse.\n- use one of the ready to go standard **kernel function** defined [here](src/header/GaussianProcess/kernel/)\n- define your own **kernel function** and build a **gaussian process** using it\n- train the **gaussian process** with the **gradient descend** approaches provided by [this](https://github.com/andreacasalino/TrainingTools) external package.\n- specify a prior distribution (for the moment only a **multivariate Gaussian**) over the hyperparameters, which is taken into accoutn when training.\n\n## CMAKE SUPPORT\n\nHaven't already left a **star**? Do it now! ;).\n\n\nThis package is completely **cross-platform** and to consume this library you can rely on [CMake](https://cmake.org).\nMore precisely, You can fetch this package and link to the **EFG** library:\n```cmake\ninclude(FetchContent)\nFetchContent_Declare(\ngauss_process\nGIT_REPOSITORY https://github.com/andreacasalino/GaussianProcesses\nGIT_TAG        main\n)\nFetchContent_MakeAvailable(gauss_process)\n```\n\nand then link to the **GP** library:\n```cmake\ntarget_link_libraries(${TARGET_NAME}\n   GaussianProcess\n)\n```\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\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandreacasalino%2Fgaussianprocesses","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandreacasalino%2Fgaussianprocesses","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandreacasalino%2Fgaussianprocesses/lists"}