{"id":19267061,"url":"https://github.com/mljs/ransac","last_synced_at":"2025-08-24T17:39:51.384Z","repository":{"id":152303005,"uuid":"618023452","full_name":"mljs/ransac","owner":"mljs","description":null,"archived":false,"fork":false,"pushed_at":"2023-06-08T14:59:38.000Z","size":102,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-08-09T10:58:46.574Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-23T15:40:20.000Z","updated_at":"2023-06-08T14:34:58.000Z","dependencies_parsed_at":null,"dependency_job_id":"1d24390f-1c96-45fd-9e1d-aba0ad499bb2","html_url":"https://github.com/mljs/ransac","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/mljs/ransac","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mljs%2Fransac","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mljs%2Fransac/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mljs%2Fransac/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mljs%2Fransac/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mljs","download_url":"https://codeload.github.com/mljs/ransac/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mljs%2Fransac/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271915556,"owners_count":24843190,"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","status":"online","status_checked_at":"2025-08-24T02:00:11.135Z","response_time":111,"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":[],"created_at":"2024-11-09T20:09:54.415Z","updated_at":"2025-08-24T17:39:51.363Z","avatar_url":"https://github.com/mljs.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ml-ransac\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\nFit a model to noisy data by excluding outliers. This is an implementation of the RANSAC algorithm..\n\n## Installation\n\n`$ npm i ml-ransac`\n\n## Examples\n\nFinding the best linear regression which doesn't take the outliers into account:\n\n```js\nimport { levenbergMarquardt } from 'ml-levenberg-marquardt'; // library allowing you to find a regression of any type\nimport { ransac } from 'ml-ransac';\n\n// defining the model function: a line\nexport type LineFunction = (x: number) =\u003e number;\n\nexport function line([a, b]: number[]): LineFunction {\n  return (x: number) =\u003e a * x + b;\n}\n\n// defining the fit function: we create a linear regression using levenberg-maquard\nexport interface LinearRegressionOptions {\n  /**\n   * Initial parameter values.\n   *\n   * @default [0,0]\n   */\n  initialValues?: number[];\n}\n\nexport function linearRegression(\n  source: number[],\n  destination: number[],\n  options: LinearRegressionOptions = {},\n): number[] {\n  const { initialValues = [0, 0] } = options;\n  const result = levenbergMarquardt({ x: source, y: destination }, line, {\n    initialValues,\n  });\n\n  return result.parameterValues;\n}\n\n// data\nconst source = [-2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];\nconst destination = [-6, -2, 0, 5, 0, 0, -1, 1, 0, 0, -1, 0, 3];\n\n// finding the best model\nconst result = ransac(source, destination, {\n  distanceFunction,\n  fitFunction,\n  modelFunction,\n  threshold: 1.1,\n  sampleSize: 2,\n  maxNbIterations: 10,\n  seed: 0,\n});\n\n// result is :\n//   {\n//     nbIterations: 10,\n//     modelParameters: [0, 0],\n//     inliers: [2, 4, 5, 6, 7, 8, 9, 10, 11],\n//     error: 1,\n//   }\n```\n\n## License\n\n[MIT](./LICENSE)\n\n[npm-image]: https://img.shields.io/npm/v/ml-ransac.svg\n[npm-url]: https://www.npmjs.com/package/ml-ransac\n[ci-image]: https://github.com/mljs/ransac/workflows/Node.js%20CI/badge.svg?branch=main\n[ci-url]: https://github.com/mljs/ransac/actions?query=workflow%3A%22Node.js+CI%22\n[codecov-image]: https://img.shields.io/codecov/c/github/mljs/ransac.svg\n[codecov-url]: https://codecov.io/gh/mljs/ransac\n[download-image]: https://img.shields.io/npm/dm/ml-ransac.svg\n[download-url]: https://www.npmjs.com/package/ml-ransac\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmljs%2Fransac","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmljs%2Fransac","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmljs%2Fransac/lists"}