{"id":19266986,"url":"https://github.com/mljs/logistic-regression","last_synced_at":"2025-04-21T19:32:29.620Z","repository":{"id":22974767,"uuid":"97813996","full_name":"mljs/logistic-regression","owner":"mljs","description":null,"archived":false,"fork":false,"pushed_at":"2022-03-03T13:15:28.000Z","size":66,"stargazers_count":18,"open_issues_count":4,"forks_count":7,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-09-17T11:07:14.954Z","etag":null,"topics":[],"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":"CHANGELOG.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":"2017-07-20T09:01:09.000Z","updated_at":"2024-02-20T08:25:52.000Z","dependencies_parsed_at":"2022-08-03T06:30:47.859Z","dependency_job_id":null,"html_url":"https://github.com/mljs/logistic-regression","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mljs%2Flogistic-regression","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mljs%2Flogistic-regression/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mljs%2Flogistic-regression/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mljs%2Flogistic-regression/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mljs","download_url":"https://codeload.github.com/mljs/logistic-regression/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223720828,"owners_count":17191895,"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":[],"created_at":"2024-11-09T20:08:52.610Z","updated_at":"2025-04-21T19:32:29.615Z","avatar_url":"https://github.com/mljs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# logistic-regression\n\n[![NPM version][npm-image]][npm-url]\n[![build status][ci-image]][ci-url]\n[![Test coverage][codecov-image]][codecov-url]\n[![npm download][download-image]][download-url]\n\nThis is an implementation of the logistic regression. When there are more than 2 classes, the method used is the _One VS All_.\n\n## Installation\n\n`$ npm i ml-logistic-regression`\n\n## Usage\n\n```js\nconst LogisticRegression = require('ml-logistic-regression');\nconst { Matrix } = require('ml-matrix');\n\n// Our training set (X,Y).\nconst X = new Matrix([[0, -1], [1, 0], [1, 1], [1, -1], [2, 0], [2, 1], [2, -1], [3, 2], [0, 4], [1, 3], [1, 4], [1, 5], [2, 3], [2, 4], [2, 5], [3, 4], [1, 10], [1, 12], [2, 10], [2, 11], [2, 14], [3, 11]]);\nconst Y = Matrix.columnVector([0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2]);\n\n// The test set (Xtest, Ytest).\nconst Xtest = new Matrix([\n  [0, -2],\n  [1, 0.5],\n  [1.5, -1],\n  [1, 2.5],\n  [2, 3.5],\n  [1.5, 4],\n  [1, 10.5],\n  [2.5, 10.5],\n  [2, 11.5],\n]);\nconst Ytest = Matrix.columnVector([0, 0, 0, 1, 1, 1, 2, 2, 2]);\n\n// We will train our model.\nconst logreg = new LogisticRegression({ numSteps: 1000, learningRate: 5e-3 });\nlogreg.train(X, Y);\n\n// We try to predict the test set.\nconst finalResults = logreg.predict(Xtest);\n\n// Now, you can compare finalResults with the Ytest, which is what you wanted to have.\n```\n\n## License\n\n[MIT](./LICENSE)\n\n[npm-image]: https://img.shields.io/npm/v/ml-logistic-regression.svg\n[npm-url]: https://npmjs.org/package/ml-logistic-regression\n[ci-image]: https://github.com/mljs/logistic-regression/workflows/Node.js%20CI/badge.svg?branch=master\n[ci-url]: https://github.com/mljs/logistic-regression/actions?query=workflow%3A%22Node.js+CI%22\n[codecov-image]: https://img.shields.io/codecov/c/github/mljs/logistic-regression.svg\n[codecov-url]: https://codecov.io/gh/mljs/logistic-regression\n[download-image]: https://img.shields.io/npm/dm/ml-logistic-regression.svg\n[download-url]: https://npmjs.org/package/ml-logistic-regression\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmljs%2Flogistic-regression","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmljs%2Flogistic-regression","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmljs%2Flogistic-regression/lists"}