{"id":16681981,"url":"https://github.com/cmccomb/smartcore_vs_linfa","last_synced_at":"2025-12-28T13:56:49.190Z","repository":{"id":89300216,"uuid":"442875190","full_name":"cmccomb/smartcore_vs_linfa","owner":"cmccomb","description":"Benchmarking the top ML crates available for Rust 🦀","archived":false,"fork":false,"pushed_at":"2022-08-19T01:54:22.000Z","size":10737,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-20T07:12:47.725Z","etag":null,"topics":["benchmark","linfa","machine-learning","rust","rust-lang","smartcore"],"latest_commit_sha":null,"homepage":"https://cmccomb.com/smartcore_vs_linfa/","language":"HTML","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/cmccomb.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":"2021-12-29T19:49:35.000Z","updated_at":"2024-02-13T15:32:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"993bef42-b1b1-4e3c-be60-b4d52068b1c0","html_url":"https://github.com/cmccomb/smartcore_vs_linfa","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmccomb%2Fsmartcore_vs_linfa","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmccomb%2Fsmartcore_vs_linfa/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmccomb%2Fsmartcore_vs_linfa/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmccomb%2Fsmartcore_vs_linfa/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cmccomb","download_url":"https://codeload.github.com/cmccomb/smartcore_vs_linfa/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243392298,"owners_count":20283560,"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":["benchmark","linfa","machine-learning","rust","rust-lang","smartcore"],"created_at":"2024-10-12T14:05:50.776Z","updated_at":"2025-12-28T13:56:49.185Z","avatar_url":"https://github.com/cmccomb.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv style=\"width:600px; height: 200px; display: table; text-align: center; margin:auto;\"\u003e\n    \u003cimg src=\"https://raw.githubusercontent.com/rust-ml/linfa/1ba884495e4e2c44d2ef68b220da1f525ad518a5/mascot.svg\" width=\"150\"\u003e \n    \u003cspan style=\"display: table-cell; vertical-align: middle; font-size: 32px;\"\u003evs\u003c/span\u003e\n    \u003cimg src=\"https://smartcorelib.org/assets/logo/smartcore.png\" width=\"150\"\u003e\n\u003c/div\u003e\n\n## About\n[`linfa`](https://rust-ml.github.io/linfa/) and [`smartcore`](https://smartcorelib.org/) have emerged as two leading `scikit-learn`-analogous machine learning frameworks for Rust. Both provide access to a number of algorithms that form the backbone of machine learning analysis. This repository provides a comparison between the training time of algorithms in these two machine learning frameworks. The algorithms included are:\n\n| Algorithm                     | Smartcore v0.4.2 | Linfa v0.7.1 | Benchmarked here? |\n|:------------------------------|:-----------------|:-------------|:------------------|\n| Linear Regression             | ✓                | ✓            | ✓                 |\n| Ridge Regression              | ✓                |              |                   |\n| LASSO Regression              | ✓                |              |                   |\n| Decision Tree Regression      | ✓                |              |                   |\n| Random Forest Regression      | ✓                |              |                   |\n| Support Vector Regression     | ✓                | ✓            | ✓                 |\n| KNN Regression                | ✓                |              |                   |\n| Elastic Net Regression        | ✓                | ✓            | ✓                 |\n| Partial Least Squares         |                  | ✓            |                   |\n| Logistic Regression           | ✓                | ✓            | ✓                 |\n| Decision Tree Classification  | ✓                | ✓            | ✓                 |\n| Random Forest Classification  | ✓                |              |                   |\n| Support Vector Classification | ✓                | ✓            | ✓                 |\n| KNN Classification            | ✓                |              |                   |\n| Gaussian Naive Bayes          | ✓                | ✓            | ✓                 |\n| K-Means                       | ✓                | ✓            | ✓                 |\n| DBSCAN                        | ✓                | ✓            | ✓                 |\n| Hierarchical Clustering       |                  | ✓            |                   |\n| Approximated DBSCAN           |                  | ✓            |                   |\n| Gaussian Mixture Model        |                  | ✓            |                   |\n| PCA                           | ✓                | ✓            | ✓                 |\n| ICA                           |                  | ✓            |                   |\n| SVD                           | ✓                |              |                   |\n| t-SNE                         |                  | ✓            |                   |\n| Diffusion Mapping             |                  | ✓            |                   |\n\nThe full report is available [here](criterion/report/index.html), but summary violin plots are provided below.\n\n## Considerations Besides Execution Time\nOver the process of creating this benchmark study, a few additional differences between the libraries emerged.\n\n### Documentation\nThe documentation for `smartcore` is a bit more consistent across algorithms. This may be due to the fact that it is maintained in a single crate.\n\n### Dependencies\nWhile `linfa` requires a BLAS/LAPACK backend (either `openblas`, `netblas`, or `intel-mkl`), `smartcore` does not. This allows `linfa` to take advantage of some additional optimization, but it limits portability.\n\n### Dataset Determinism\nBenchmark datasets are now generated from deterministic random seeds that pair each [`TestSize`](https://docs.rs/smartcore_vs_linfa/latest/smartcore_vs_linfa/enum.TestSize.html) with a scenario (`regression`, `classification`, or `clustering`). This ensures that all cached helpers (`xy_regression`, `xy_classification`, and `x_unsupervised`) draw from reproducible inputs across runs, aligning the smartcore and linfa comparisons.\n\n## Results\n### Regression\n#### [Linear Regression](criterion/Linear%20Regression/report/index.html)\n_No customization needed to equate algorithms._\n\n![](criterion/Linear%20Regression/report/violin.svg)\n\n#### [Elastic Net](criterion/Elastic%20Net/report/index.html)\n\n![](criterion/Elastic%20Net/report/violin.svg)\n\n\n#### [Support Vector Regression](criterion/Support%20Vector%20Regression/report/index.html)\n\n![](criterion/Support%20Vector%20Regression/report/violin.svg)\n\n\n\n### Classification\n#### [Logistic Regression](criterion/Logistic%20Regression/report/index.html)\n\nThe `smartcore` implementation has no parameters, but the `linfa` settings were modified to align it with `smartcore` defaults:\n\n- Gradient tolerance set to `1e-8`\n- Maximum number of iterations set to `1000`\n\n![](criterion/Logistic%20Regression/report/violin.svg)\n\n#### [Decision Tree](criterion/Decision%20Tree%20Classification/report/index.html)\n\n![](criterion/Decision%20Tree%20Classification/report/violin.svg)\n\n#### [Gaussian Naive Bayes](criterion/Gaussian%20Naive%20Bayes/report/index.html)\n\n![](criterion/Gaussian%20Naive%20Bayes/report/violin.svg)\n\n#### [Support Vector Classification](criterion/Support%20Vector%20Classification/report/index.html)\n\n![](criterion/Support%20Vector%20Classification/report/violin.svg)\n\n\n\n### Clustering\n#### [K-Means](criterion/K-Means%20Clustering/report/index.html)\n\nSince the two implementations use different convergence criteria, the number of max iterations was equated at a low value, and only 1 run of the `linfa` algorithm was permitted:\n\n- Max iterations set to `10`\n- Number of runs set to `1`\n\n![](criterion/K-Means%20Clustering/report/violin.svg)\n\n#### [DBSCAN](criterion/DBSCAN%20Clustering/report/index.html)\n\n![](criterion/DBSCAN%20Clustering/report/violin.svg)\n\n### Dimensionality Reduction\n#### [PCA](criterion/PCA/report/index.html)\n![](criterion/PCA/report/violin.svg)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcmccomb%2Fsmartcore_vs_linfa","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcmccomb%2Fsmartcore_vs_linfa","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcmccomb%2Fsmartcore_vs_linfa/lists"}