{"id":20399413,"url":"https://github.com/caffik/libml","last_synced_at":"2026-07-07T06:31:38.668Z","repository":{"id":250927108,"uuid":"835827827","full_name":"caffik/libml","owner":"caffik","description":"Simple library that implements some machine learning algorithms","archived":false,"fork":false,"pushed_at":"2024-09-19T18:11:37.000Z","size":64,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-25T15:42:49.862Z","etag":null,"topics":["cmake","cpp","machine-learning"],"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/caffik.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-30T15:55:08.000Z","updated_at":"2024-09-19T18:11:40.000Z","dependencies_parsed_at":"2025-01-15T10:54:05.238Z","dependency_job_id":"be9868ea-3f4f-42cb-8605-42ea1103d2db","html_url":"https://github.com/caffik/libml","commit_stats":null,"previous_names":["caffik/libml"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/caffik/libml","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caffik%2Flibml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caffik%2Flibml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caffik%2Flibml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caffik%2Flibml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/caffik","download_url":"https://codeload.github.com/caffik/libml/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caffik%2Flibml/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35218117,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-07T02:00:07.222Z","response_time":90,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["cmake","cpp","machine-learning"],"created_at":"2024-11-15T04:29:03.933Z","updated_at":"2026-07-07T06:31:38.648Z","avatar_url":"https://github.com/caffik.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# libml\n\n`libml` is a simple, header-only library that implements machine learning algorithms, currently featuring a classifier\nbased on Singular Value Decomposition (SVD).\n\n## Features\n\n- **Header-only**: Easy to integrate into your project.\n- **Fast Computations**: Utilizes [Eigen](https://eigen.tuxfamily.org/index.php?title=Main_Page) for matrix operations\n  and [BS::thread_pool](https://github.com/bshoshany/thread-pool) for parallel processing.\n\n## Description\n\n- `projection.hpp`: contains functions for projecting the columns of one matrix onto the columns of another matrix.\n- `svd_classifier.hpp`: defines the SVDClassifier class, which uses Singular Value Decomposition (SVD) for\n  classification tasks. The class includes methods for fitting the model, predicting labels, and managing the data.\n\n## Project Structure\n\n- `include/libml/`: Header files\n- `tests/`: Unit tests\n- `docs/`: Documentation files\n\n## Installation\n\nTo use `libml`, include the header files in your project:\n\n```cpp\n#include \"libml/svd_classifier/svd_classifier.hpp\"\n```\n\n### Dependencies\n\n`libml` depends on the following libraries:\n\n- [Eigen3](https://eigen.tuxfamily.org/index.php?title=Main_Page)\n- [BS::thread_pool](https://github.com/bshoshany/thread-pool)\n\n### Using CMake\n\nIt is highly recommended to use CMake (version 3.28 or later) to manage your project. Add the following to your\n`CMakeLists.txt`:\n\n```cmake\n# libml requires at least C++17\nset(CMAKE_CXX_STANDARD 17)\nset(CMAKE_CXX_STANDARD_REQUIRED ON)\n\ninclude(FetchContent)\nFetchContent_Declare(\n        libml\n        GIT_REPOSITORY https://github.com/caffik/libml\n        GIT_TAG v1.0.0\n)\n\nFetchContent_MakeAvailable(libml)\n```\n\nThen link the library using the `target_link_libraries` command.\n\n## CMake Options\n\n- `ENABLE_TESTING`: Build tests for the library. Default is `OFF`.\n\n## SVD Classifier\n\nThe `SVDClassifier` class is designed for flexibility and ease of use.\n\n## Documentation\n\nTo generate the documentation for `libml`, you need to have Doxygen and LaTeX installed on your system.\nThe CMake configuration will automatically detect these tools and generate the necessary documentation files.\n\n### Requirements\n\n- **Doxygen**: Used to generate HTML documentation.\n- **LaTeX**: Specifically, the `pdflatex` compiler is used to generate PDF documentation.\n\n## Examples\n\nThis example demonstrates how to use the `projection` function.\n\n```cpp\n#include \u003ciostream\u003e\n#include \u003cEigen/Core\u003e\n#include \"libml/utils/projection.hpp\"\n\nint main() {\n  // Example matrices\n  Eigen::MatrixXd from(3, 2);\n  from \u003c\u003c 1, 2,\n          3, 4,\n          5, 6;\n\n  Eigen::MatrixXd onto(3, 2);\n  onto \u003c\u003c 1, 0,\n          0, 1,\n          0, 0;\n\n  Eigen::MatrixXd result = ml::projection(from, onto);\n  std::cout \u003c\u003c \"Projection result:\\n\" \u003c\u003c result \u003c\u003c std::endl;\n  return 0;\n}\n``` \nThis example demonstrates how to use the SVDClassifier class.\n\n```cpp\n#include \u003ciostream\u003e\n#include \u003cEigen/Core\u003e\n#include \"libml/svd_classification/svd_classifier.hpp\"\n\nint main() {\n  // Example data [here each matrix represents a training set where each row is a sample]\n  // [by default the data sets are labeled: 0, 1, 2, ...]\n  std::vector\u003cEigen::MatrixXd\u003e data = {\n      Eigen::MatrixXd::Random(4, 4),    // label 0 \n      Eigen::MatrixXd::Random(4, 4),    // label 1\n      Eigen::MatrixXd::Random(4, 4)     // label 2\n  }\n  // Create SVDClassifier instance\n  ml::SVDClassifier classifier(data);\n  \n  // Fit the model\n  classifier.fit();\n  \n  // Predict labels for new data\n  auto new_data{Eigen::MatrixXd::Random(4, 4)};\n  auto labels{classifier.fit_predict(new_data)}; // each row of new_data represents a sample \n  // for which the label is predicted\n  \n  std::cout \u003c\u003c \"Predicted labels:\\n\" \u003c\u003c labels \u003c\u003c std::endl\n  return 0;\n}\n```\n\n### Potential Improvements\n\n- **Randomized SVD**: The current implementation uses classical SVD. Introducing a randomized SVD algorithm could\n  improve performance. For more information, see [this paper](https://epubs.siam.org/doi/10.1137/090771806) and a C++\n  implementation [here](https://github.com/mp4096/rsvd).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcaffik%2Flibml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcaffik%2Flibml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcaffik%2Flibml/lists"}