{"id":19267032,"url":"https://github.com/mljs/svm","last_synced_at":"2025-04-21T19:32:32.535Z","repository":{"id":33406621,"uuid":"37051822","full_name":"mljs/svm","owner":"mljs","description":"Support Vector Machine in Javascript","archived":false,"fork":false,"pushed_at":"2018-04-26T10:42:36.000Z","size":1254,"stargazers_count":39,"open_issues_count":1,"forks_count":7,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-04-17T16:56:08.674Z","etag":null,"topics":["javascript","support-vector-machine","svm","svm-classifier","svm-model"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mljs.png","metadata":{"files":{"readme":"README.md","changelog":"History.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-06-08T07:18:32.000Z","updated_at":"2025-02-13T19:59:56.000Z","dependencies_parsed_at":"2022-09-05T21:02:05.085Z","dependency_job_id":null,"html_url":"https://github.com/mljs/svm","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mljs%2Fsvm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mljs%2Fsvm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mljs%2Fsvm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mljs%2Fsvm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mljs","download_url":"https://codeload.github.com/mljs/svm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250120081,"owners_count":21378135,"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":["javascript","support-vector-machine","svm","svm-classifier","svm-model"],"created_at":"2024-11-09T20:09:34.381Z","updated_at":"2025-04-21T19:32:32.519Z","avatar_url":"https://github.com/mljs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ml-svm\n\n  [![NPM version][npm-image]][npm-url]\n  [![build status][travis-image]][travis-url]\n  [![David deps][david-image]][david-url]\n  [![npm download][download-image]][download-url]\n  \nSupport Vector Machines in Javascript\n\n## :warning: :warning: This is a simplified implementation of SVM, primarily meant for students to understand the algorithm. For real world applications, please check out [libsvm-js](https://github.com/mljs/libsvm) :warning: :warning:\n\nImplementation of [this simplified Sequential Minimization Optimization algorithm](http://cs229.stanford.edu/materials/smo.pdf)\n\n## Installation\n\n`npm install ml-svm`\n\n## API\n[API documentation](https://mljs.github.io/svm)\n\n## Example\n\n```js\n// Instantiate the svm classifier\nvar SVM = require('ml-svm');\n\nvar options = {\n  C: 0.01,\n  tol: 10e-4,\n  maxPasses: 10,\n  maxIterations: 10000,\n  kernel: 'rbf',\n  kernelOptions: {\n    sigma: 0.5\n  }\n};\n\nvar svm = new SVM(options);\n\n// Train the classifier - we give him an xor\nvar features = [[0,0],[0,1],[1,1],[1,0]];\nvar labels = [1, -1, 1, -1];\nsvm.train(features, labels);\n\n// Let's see how narrow the margin is\nvar margins = svm.margin(features);\n\n// Let's see if it is separable by testing on the training data\nsvm.predict(features); // [1, -1, 1, -1]\n\n// I want to see what my support vectors are\nvar supportVectors = svm.supportVectors();\n \n// Now we want to save the model for later use\nvar model = svm.toJSON();\n\n/// ... later, you can make predictions without retraining the model\nvar importedSvm = SVM.load(model);\nimportedSvm.predict(features); // [1, -1, 1, -1] \n```\n\n\n## Authors\n\n  - [Miguel Asencio](https://github.com/maasencioh)\n  - [Daniel Kostro](https://github.com/stropitek)\n\n## License\n\n  [MIT](./LICENSE)\n\n[npm-image]: https://img.shields.io/npm/v/ml-svm.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/ml-svm\n[travis-image]: https://img.shields.io/travis/mljs/svm/master.svg?style=flat-square\n[travis-url]: https://travis-ci.org/mljs/svm\n[david-image]: https://img.shields.io/david/mljs/svm.svg?style=flat-square\n[david-url]: https://david-dm.org/mljs/svm\n[download-image]: https://img.shields.io/npm/dm/ml-svm.svg?style=flat-square\n[download-url]: https://npmjs.org/package/ml-svm\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmljs%2Fsvm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmljs%2Fsvm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmljs%2Fsvm/lists"}