{"id":19267079,"url":"https://github.com/mljs/random-forest","last_synced_at":"2025-04-13T06:40:23.754Z","repository":{"id":9878008,"uuid":"63634712","full_name":"mljs/random-forest","owner":"mljs","description":"Random forest for classification and regression.","archived":false,"fork":false,"pushed_at":"2022-03-02T13:05:49.000Z","size":3152,"stargazers_count":62,"open_issues_count":6,"forks_count":21,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-01-24T11:11:29.288Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://mljs.github.io/random-forest/","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":"2016-07-18T20:26:43.000Z","updated_at":"2025-01-06T10:15:34.000Z","dependencies_parsed_at":"2022-08-07T05:15:13.006Z","dependency_job_id":null,"html_url":"https://github.com/mljs/random-forest","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mljs%2Frandom-forest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mljs%2Frandom-forest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mljs%2Frandom-forest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mljs%2Frandom-forest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mljs","download_url":"https://codeload.github.com/mljs/random-forest/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248675434,"owners_count":21143763,"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:10:01.251Z","updated_at":"2025-04-13T06:40:23.733Z","avatar_url":"https://github.com/mljs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ml-random-forest\n\n[![NPM version][npm-image]][npm-url]\n[![build status][ci-image]][ci-url]\n[![npm download][download-image]][download-url]\n\n[Random forest for classification and regression](https://en.wikipedia.org/wiki/Random_forest).\n\n## Installation\n\n`npm i ml-random-forest`\n\n## [API Documentation](https://mljs.github.io/random-forest/)\n\n## Usage\n\n### As classifier\n\n```js\nimport IrisDataset from 'ml-dataset-iris';\nimport { RandomForestClassifier as RFClassifier } from 'ml-random-forest';\n\nconst trainingSet = IrisDataset.getNumbers();\nconst predictions = IrisDataset.getClasses().map((elem) =\u003e\n  IrisDataset.getDistinctClasses().indexOf(elem)\n);\n\nconst options = {\n  seed: 3,\n  maxFeatures: 0.8,\n  replacement: true,\n  nEstimators: 25\n};\n\nconst classifier = new RFClassifier(options);\nclassifier.train(trainingSet, predictions);\nconst result = classifier.predict(trainingSet);\nconst oobResult = classifier.predictOOB();\nconst confusionMatrix = classifier.getConfusionMatrix();\n```\n\n### As regression\n\n```js\nimport { RandomForestRegression as RFRegression } from 'ml-random-forest';\n\nconst dataset = [\n  [73, 80, 75, 152],\n  [93, 88, 93, 185],\n  [89, 91, 90, 180],\n  [96, 98, 100, 196],\n  [73, 66, 70, 142],\n  [53, 46, 55, 101],\n  [69, 74, 77, 149],\n  [47, 56, 60, 115],\n  [87, 79, 90, 175],\n  [79, 70, 88, 164],\n  [69, 70, 73, 141],\n  [70, 65, 74, 141],\n  [93, 95, 91, 184],\n  [79, 80, 73, 152],\n  [70, 73, 78, 148],\n  [93, 89, 96, 192],\n  [78, 75, 68, 147],\n  [81, 90, 93, 183],\n  [88, 92, 86, 177],\n  [78, 83, 77, 159],\n  [82, 86, 90, 177],\n  [86, 82, 89, 175],\n  [78, 83, 85, 175],\n  [76, 83, 71, 149],\n  [96, 93, 95, 192]\n];\n\nconst trainingSet = new Array(dataset.length);\nconst predictions = new Array(dataset.length);\n\nfor (let i = 0; i \u003c dataset.length; ++i) {\n  trainingSet[i] = dataset[i].slice(0, 3);\n  predictions[i] = dataset[i][3];\n}\n\nconst options = {\n  seed: 3,\n  maxFeatures: 2,\n  replacement: false,\n  nEstimators: 200\n};\n\nconst regression = new RFRegression(options);\nregression.train(trainingSet, predictions);\nconst result = regression.predict(trainingSet);\n```\n\n## License\n\n[MIT](./LICENSE)\n\n[npm-image]: https://img.shields.io/npm/v/ml-random-forest.svg\n[npm-url]: https://npmjs.org/package/ml-random-forest\n[ci-image]: https://github.com/mljs/random-forest/workflows/Node.js%20CI/badge.svg?branch=master\n[ci-url]: https://github.com/mljs/random-forest/actions?query=workflow%3A%22Node.js+CI%22\n[download-image]: https://img.shields.io/npm/dm/ml-random-forest.svg\n[download-url]: https://npmjs.org/package/ml-random-forest\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmljs%2Frandom-forest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmljs%2Frandom-forest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmljs%2Frandom-forest/lists"}