{"id":21973309,"url":"https://github.com/franciscoda/psvm","last_synced_at":"2026-04-18T15:37:27.639Z","repository":{"id":81195962,"uuid":"168729236","full_name":"FranciscoDA/psvm","owner":"FranciscoDA","description":"R package and C++ library that allows training SVM models in a GPU using CUDA and predicting out-of-sample data. A support vector machine (SVM) is a type of machine learning model that is trained using supervised data to classify samples.","archived":false,"fork":false,"pushed_at":"2019-02-17T04:24:40.000Z","size":12095,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-12T02:03:12.205Z","etag":null,"topics":["cpp","cpp17","cuda","machine-learning","r","svm-classifier","svm-training"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FranciscoDA.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":"2019-02-01T16:46:08.000Z","updated_at":"2023-08-29T22:45:15.000Z","dependencies_parsed_at":"2023-05-25T05:15:42.808Z","dependency_job_id":null,"html_url":"https://github.com/FranciscoDA/psvm","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/FranciscoDA/psvm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FranciscoDA%2Fpsvm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FranciscoDA%2Fpsvm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FranciscoDA%2Fpsvm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FranciscoDA%2Fpsvm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FranciscoDA","download_url":"https://codeload.github.com/FranciscoDA/psvm/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FranciscoDA%2Fpsvm/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31974946,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T00:39:45.007Z","status":"online","status_checked_at":"2026-04-18T02:00:07.018Z","response_time":103,"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":["cpp","cpp17","cuda","machine-learning","r","svm-classifier","svm-training"],"created_at":"2024-11-29T15:26:27.562Z","updated_at":"2026-04-18T15:37:27.602Z","avatar_url":"https://github.com/FranciscoDA.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# psvm\nSequential and parallel (CUDA) implementations of SVM classifiers.\n\nThis project is divided among three main subprojects:\n * **libpsvm**: library implementing support vector machines, classifiers, training and decision algorithms. libpsvm contains two static libraries: `libsvm` and `libcusvm`. While the former performs sequential training, the later may train in parallel using CUDA GPGPU.\n * **psvm-cli**: command line interface that allows for training, testing and prediction of classifier models with data from CSV or IDX (MNIST) datasets. `psvm-cli` generates two executables named svm and cusvm. The former links to `libsvm` and the later to `libcusvm`.\n * **psvm4r**: R package with bindings to libpsvm. Note that currently `psvm4r` only links with libsvm.\n \n\n## Requirements\n * CMake 3.4+\n * Boost 1.55\n * C++11 compiler\n * CUDA 8.0 SDK (optional)\n * R with Rcpp package (optional)\n\n## Compilation\n * Clone this repository: `git clone https://github.com/franciscoda/psvm`\n * Download git submodules: `git submodule init \u0026\u0026 git submodule update -f`\n * Create build directory: `mkdir build \u0026\u0026 cd build`\n * Run CMake from the build directory: `cmake ..`\n   * Optionally, specify a CUDA architecture. If CMake\u003c=3.8: `cmake .. -DCUDA_NVCC_FLAGS=\"-arch=sm_30\"`, else if CMake\u003e3.8: `cmake .. -DCMAKE_CUDA_FLAGS=\"-arch=sm_30\"`\n   * Optionally, generate position-independent code. This is required if you plan to build psvm4r, since psvm4r builds a shared library. `cmake .. -DCMAKE_POSITION_INDEPENDENT_CODE=ON`\n * Compile: `make`\n * The output paths for the CLI executables executables are `build/bin/svm` and `build/bin/cusvm`\n * The output paths for the static libraries are `build/lib/libsvm.a` and `build/lib/libcusvm.a`\n\n## psvm-cli\n\npsvm-cli provides most of the features implemented in libpsvm, plus some basic I/O and data preprocessing functions. Run `bin/svm --help` or `bin/cusvm --help` to see a list of parameters.\n\n### Supported input formats\n * CSV\n * IDX (see the MNIST handwritten digit dataset format, also check the `mnist/` subdirectory)\n\nNote that attributes and labels must be in separate files.\n\n### Supported normalization methods:\n * `--nz`: (x-mean)/stdev. Each attribute is scaled according to the normal distribution\n * `--n1`: (x-min)/(max-min). Each attribute is scaled to \\[0;1\\] range\n * `--n2`: -1 + (x-min)\\*(1-(-1))/(max-min). Each attribute is scaled to \\[-1;1\\] range\n\n### Supported kernels\n * `--linear`: xi \\* xj\n * `--polynomial`: (xi\\*xj+c)^d\n * `--gaussian`: exp(-gamma * ||xi-xj||^2)\n\n### Supported multiclass classification methods\n * `--1A1` - One against one (trains k\\*(k-1)/2 reduced models)\n * `--1AA` - One against all (trains k models)\n\n## psvm4r\n\n### Compilation and installation\nRun `R CMD INSTALL psvm4r` from the root directory of the project. This should install the package in your user packages directory.\nWhen editing the source code, it may be necessary to recompile the attributes. Run the following commands in an R prompt from the root directory of this project:\n```R\nlibrary(Rcpp)\nRcpp::compileAttributes('psvm4r')\n```\n\n### Description\nThere are several S4 classes implemented in psvm4r that bind to libpsvm objects. We can divide them among Kernel and Classifier classes:\n\n#### Kernel classes\nThese classes support an `object$get(x,y)` method. Where `x` and `y` are numeric vectors. This returns the element in the kernel matrix for vectors `x` and `y`.\nThe following classes are available with their respective constructor parameters:\n * `LinearKernel()`\n * `PolynomialKernel(degree, constant)`\n * `RbfKernel(gamma)`\n\n#### Classifier classes\nThese classes support the following methods:\n * `object$train(attributes, labels, C)`. Where `attributes` is a single- or multi-dimensional vector of numeric attributes, `labels` is a single vector of integer labels and `C` is a numeric value for the regularization parameter.\n * `object$predict(attributes)`. Predicts on a trained classifier object.\n\nThe following classes are available with their respective constructor parameters:\n * `OneAgainstOneCSVC(num_classes, num_dimensions, K)`\n * `OneAgainstAllCSVC(num_classes, num_dimensions, K)`\n\n### Demos\nThere are a few demos included, demonstrating the decision boundaries of each kernel. To run them, run one of the following from the R command line:\n * `demo('linear')`\n * `demo('quadratic')`\n * `demo('rbf')`\n\n![linear](https://i.imgur.com/8HEZaOm.png)\n![quadratic](https://i.imgur.com/u0h3CiZ.png)\n![rbf](https://i.imgur.com/FrWpzFm.png)\n\n## References / Recommended reads:\n * [Buttou, L., Lin, C. (2006). *Support Vector Machine Solvers*.](http://leon.bottou.org/publications/pdf/lin-2006.pdf)\n * [Burges, C. (1998). *A Tutorial on support Vector Machines for Pattern Recognition*.](http://www.di.ens.fr/~mallat/papiers/svmtutorial.pdf)\n * [Chang, C., Lin, C. (2001). *LIBSVM: A Library for Support Vector Machines*.](https://www.csie.ntu.edu.tw/~cjlin/papers/libsvm.pdf)\n * [Berwick, R. *An Idiot's Guide to Support Vector Machines (SVMs).*](http://web.mit.edu/6.034/wwwbob/svm-notes-long-08.pdf)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffranciscoda%2Fpsvm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffranciscoda%2Fpsvm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffranciscoda%2Fpsvm/lists"}