{"id":13426293,"url":"https://github.com/Tom-Alexander/regression-js","last_synced_at":"2025-03-15T21:30:53.842Z","repository":{"id":6222651,"uuid":"7454062","full_name":"Tom-Alexander/regression-js","owner":"Tom-Alexander","description":"Curve Fitting in JavaScript.","archived":false,"fork":false,"pushed_at":"2022-12-06T19:46:27.000Z","size":1751,"stargazers_count":944,"open_issues_count":45,"forks_count":131,"subscribers_count":30,"default_branch":"master","last_synced_at":"2025-03-09T06:01:50.922Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://tom-alexander.github.io/regression-js/","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/Tom-Alexander.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":"2013-01-05T09:53:33.000Z","updated_at":"2025-03-05T17:30:31.000Z","dependencies_parsed_at":"2022-08-30T18:22:16.928Z","dependency_job_id":null,"html_url":"https://github.com/Tom-Alexander/regression-js","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/Tom-Alexander%2Fregression-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tom-Alexander%2Fregression-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tom-Alexander%2Fregression-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tom-Alexander%2Fregression-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Tom-Alexander","download_url":"https://codeload.github.com/Tom-Alexander/regression-js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243792319,"owners_count":20348618,"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-07-31T00:01:31.150Z","updated_at":"2025-03-15T21:30:53.556Z","avatar_url":"https://github.com/Tom-Alexander.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","Javascript"],"sub_categories":["Tools","[Tools](#tools-1)","Speech Recognition"],"readme":"\n\u003cdiv align=\"center\"\u003e\n\u003ch1\u003eregression-js\u003c/h1\u003e\n\u003ca href=\"https://travis-ci.org/Tom-Alexander/regression-js\"\u003e\n\u003cimg src=\"https://travis-ci.org/Tom-Alexander/regression-js.svg?branch=master\"/\u003e\n\u003c/a\u003e\n\u003ca href=\"https://npmjs.com/package/regression\"\u003e\n\u003cimg src=\"https://img.shields.io/npm/v/regression.svg\" alt=\"npm version\" /\u003e\n\u003c/a\u003e\n\u003ca href=\"https://npmjs.com/package/regression\"\u003e\n\u003cimg src=\"https://img.shields.io/npm/dt/regression.svg\" alt=\"npm downloads\" /\u003e\n\u003c/a\u003e\n\u003ca href=\"https://codeclimate.com/github/Tom-Alexander/regression-js/coverage\"\u003e\u003cimg src=\"https://codeclimate.com/github/Tom-Alexander/regression-js/badges/coverage.svg\" /\u003e\u003c/a\u003e\n\u003cbr/\u003e\n\u003cbr/\u003e\n\u003cp\u003e\nregression-js is a JavaScript module containing a collection of linear least-squares fitting methods for simple data analysis.\n\u003c/p\u003e\n\u003c/div\u003e\n\n## Installation\nThis module works on node and in the browser. It is available as the 'regression' package on [npm](https://www.npmjs.com/package/regression). It is also available on a [CDN](https://cdnjs.com/libraries/regression).\n\n### npm\n\n```\nnpm install --save regression\n```\n\n## Usage\n\n```javascript\nimport regression from 'regression';\nconst result = regression.linear([[0, 1], [32, 67], [12, 79]]);\nconst gradient = result.equation[0];\nconst yIntercept = result.equation[1];\n```\n\nData is passed into the model as an array. A second parameter can be used to configure the model. The configuration parameter is optional. `null` values are ignored. The precision option will set the number of significant figures the output is rounded to.\n\n### Configuration options\nBelow are the default values for the configuration parameter.\n```javascript\n{\n  order: 2,\n  precision: 2,\n}\n```\n\n### Properties\n- `equation`: an array containing the coefficients of the equation\n- `string`: A string representation of the equation\n- `points`: an array containing the predicted data in the domain of the input\n- `r2`: the coefficient of determination (\u003ci\u003eR\u003c/i\u003e\u003csup\u003e2\u003c/sup\u003e)\n- `predict(x)`: This function will return the predicted value\n\n## API\n\n### `regression.linear(data[, options])`\nFits the input data to a straight line with the equation ![y = mx + c](http://mathurl.com/ycqyhets.png). It returns the coefficients in the form `[m, c]`.\n\n### `regression.exponential(data[, options])`\nFits the input data to a exponential curve with the equation ![y = ae^bx](http://mathurl.com/zuys53z.png). It returns the coefficients in the form `[a, b]`.\n\n### `regression.logarithmic(data[, options])`\nFits the input data to a logarithmic curve with the equation ![y = a + b ln x](http://mathurl.com/zye394m.png). It returns the coefficients in the form `[a, b]`.\n\n### `regression.power(data[, options])`\nFits the input data to a power law curve with the equation ![y = ax^b](http://mathurl.com/gojkazs.png). It returns the coefficients in the form `[a, b]`.\n\n### `regression.polynomial(data[, options])`\nFits the input data to a polynomial curve with the equation ![anx^n ... + a1x + a0](http://mathurl.com/hxz543o.png). It returns the coefficients in the form `[an..., a1, a0]`. The order can be configure with the `order` option.\n\n#### Example\n\n```javascript\nconst data = [[0,1],[32, 67] .... [12, 79]];\nconst result = regression.polynomial(data, { order: 3 });\n```\n\n## Development\n\n- Install the dependencies with `npm install`\n- To build the assets in the `dist` directory, use `npm run build`\n- You can run the tests with: `npm run test`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTom-Alexander%2Fregression-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FTom-Alexander%2Fregression-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTom-Alexander%2Fregression-js/lists"}