{"id":21397306,"url":"https://github.com/silviucpp/esvm","last_synced_at":"2026-02-20T22:02:25.198Z","repository":{"id":179670655,"uuid":"663949982","full_name":"silviucpp/esvm","owner":"silviucpp","description":"An erlang library for Support Vector Machine (SVM) classification and regression","archived":false,"fork":false,"pushed_at":"2025-03-04T15:01:51.000Z","size":228,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-18T05:09:50.561Z","etag":null,"topics":["erlang","support-vector-machine","svm"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/silviucpp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2023-07-08T14:13:36.000Z","updated_at":"2025-03-04T15:01:43.000Z","dependencies_parsed_at":null,"dependency_job_id":"77220df1-8638-4bdc-a645-5a9c2477b79e","html_url":"https://github.com/silviucpp/esvm","commit_stats":null,"previous_names":["silviucpp/esvm"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/silviucpp/esvm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silviucpp%2Fesvm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silviucpp%2Fesvm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silviucpp%2Fesvm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silviucpp%2Fesvm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/silviucpp","download_url":"https://codeload.github.com/silviucpp/esvm/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silviucpp%2Fesvm/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29666432,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-20T19:49:36.704Z","status":"ssl_error","status_checked_at":"2026-02-20T19:44:05.372Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["erlang","support-vector-machine","svm"],"created_at":"2024-11-22T14:41:35.386Z","updated_at":"2026-02-20T22:02:25.177Z","avatar_url":"https://github.com/silviucpp.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# esvm\n\n[![Build Status](https://app.travis-ci.com/silviucpp/esvm.svg?branch=main)](https://travis-ci.com/github/silviucpp/esvm)\n[![GitHub](https://img.shields.io/github/license/silviucpp/esvm)](https://github.com/silviucpp/esvm/blob/main/LICENSE)\n[![Hex.pm](https://img.shields.io/hexpm/v/esvm)](https://hex.pm/packages/esvm)\n\n`esvm` is a simple, easy-to-use, and efficient Erlang library for **Support Vector Machine (SVM)** classification and regression, based on [libsvm](https://github.com/cjlin1/libsvm). It supports:\n\n- C-SVM classification\n- Nu-SVM classification\n- One-class SVM\n- Epsilon-SVM regression\n- Nu-SVM regression\n\n## Overview\n\nThe **Support Vector Machine (SVM)** is a widely recognized technique for classifying large feature spaces reliably. It is a statistical model that leverages machine learning to capture complex relationships between variables.\n\nThe core idea of SVM is to find an optimal hyperplane that distinguishes between different classes. This hyperplane is selected to maximize the margin, ensuring superior generalization. SVMs perform exceptionally well in high-dimensional spaces and use memory efficiently by relying on a subset of training data points for decision-making.\n\nHowever, SVMs may become inefficient when the number of features exceeds the number of samples.\n\n## Quick Start\n\n### Compile the project\n\n```sh\nrebar3 compile\n```\n\n### Create a model\n\n```erlang\n% Features should be a list of tuples where the first element is the class\n% and the second is the feature vector.\n\nFeatures = [\n    {1, [1, 3, 4, 5]},\n    {0, [0, 2, 4, 6]},\n    {1, [0, 2, 4, 6]}\n],\n\nFeaturesCount = length(Features),\n\n{ok, Model} = esvm:model_create(Features, FeaturesCount, [\n    {\u003c\u003c\"svm_type\"\u003e\u003e, ?SVM_TYPE_C_SVC},\n    {\u003c\u003c\"kernel_type\"\u003e\u003e, ?KERNEL_TYPE_RBF}\n]).\n```\n\n### Model parameters\n\nWhen creating a model, the following parameters can be tuned:\n\n- **`svm_type`**: One of the `SVM_TYPE_*` values from `esvm.hrl`. Default is `SVM_TYPE_C_SVC`.\n- **`kernel_type`**: One of the `KERNEL_TYPE_*` values from `esvm.hrl`. Default is `KERNEL_TYPE_RBF`.\n- **`degree`**: Degree in the kernel function (default `3`).\n- **`gamma`**: Gamma in the kernel function (default is `1 / max feature length`).\n- **`coef0`**: Coefficient for the kernel function (default `0`).\n- **`cache_size`**: Cache memory size in MB (default `100`).\n- **`eps`**: Tolerance for the termination criterion (default `0.001`).\n- **`C`**: The `C` (cost) parameter for C-SVC, epsilon-SVR, and nu-SVR (default `1`).\n- **`nu`**: The `nu` parameter for nu-SVC, one-class SVM, and nu-SVR (default `0.5`).\n- **`p`**: Epsilon in the loss function of epsilon-SVR (default `0.1`).\n- **`shrinking`**: Whether to use shrinking heuristics, 0 or 1 (default `1`).\n- **`probability`**: Whether to train a model for probability estimates, 0 or 1 (default `0`).\n\n### Save a model\n\n```erlang\ntrue = esvm:model_save(Model, \u003c\u003c\"path/file.model\"\u003e\u003e).\n```\n\n### Load an existing model\n\n```erlang\n{ok, Model} = esvm:model_load(\u003c\u003c\"path/file.model\"\u003e\u003e).\n```\n\n### Make a prediction\n\n```erlang\n{ok, PredictedClass} = esvm:model_predict(Model, Feature).\n```\n\n## Tests\n\nInside the `classification_test.erl` file in the `test` folder, you will find an example of creating a model to classify SMS messages as spam or not using SVM.\n\nThe dataset used to train the model can be downloaded from [here](https://archive.ics.uci.edu/dataset/228/sms+spam+collection).\n\nTo run the tests, execute the following command from the project root:\n\n```sh\nrebar3 eunit\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsilviucpp%2Fesvm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsilviucpp%2Fesvm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsilviucpp%2Fesvm/lists"}