{"id":19267071,"url":"https://github.com/mljs/decision-tree-cart","last_synced_at":"2025-04-21T19:32:34.529Z","repository":{"id":4812417,"uuid":"41787854","full_name":"mljs/decision-tree-cart","owner":"mljs","description":"Decision trees using CART implementation","archived":false,"fork":false,"pushed_at":"2022-03-04T07:51:08.000Z","size":1397,"stargazers_count":23,"open_issues_count":3,"forks_count":20,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-04-01T15:41:55.992Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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":"2015-09-02T07:55:31.000Z","updated_at":"2024-11-14T15:12:41.000Z","dependencies_parsed_at":"2022-08-06T18:00:28.958Z","dependency_job_id":null,"html_url":"https://github.com/mljs/decision-tree-cart","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mljs%2Fdecision-tree-cart","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mljs%2Fdecision-tree-cart/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mljs%2Fdecision-tree-cart/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mljs%2Fdecision-tree-cart/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mljs","download_url":"https://codeload.github.com/mljs/decision-tree-cart/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250120089,"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":[],"created_at":"2024-11-09T20:09:57.764Z","updated_at":"2025-04-21T19:32:34.524Z","avatar_url":"https://github.com/mljs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ml-cart (Classification and regression trees)\n\n[![NPM version][npm-image]][npm-url]\n[![build status][ci-image]][ci-url]\n[![npm download][download-image]][download-url]\n\nDecision trees using CART implementation.\n\n## Installation\n\n`npm i ml-cart`\n\n## [API documentation](http://mljs.github.io/decision-tree-cart/)\n\n## Usage\n\n### As a classifier\n\n```js\nimport irisDataset from 'ml-dataset-iris';\nimport { DecisionTreeClassifier as DTClassifier } from 'ml-cart';\n\nconst trainingSet = irisDataset.getNumbers();\nconst predictions = irisDataset\n  .getClasses()\n  .map((elem) =\u003e irisDataset.getDistinctClasses().indexOf(elem));\n\nconst options = {\n  gainFunction: 'gini',\n  maxDepth: 10,\n  minNumSamples: 3,\n};\n\nconst classifier = new DTClassifier(options);\nclassifier.train(trainingSet, predictions);\nconst result = classifier.predict(trainingSet);\n```\n\n### As a regression\n\n```js\nimport { DecisionTreeRegression as DTRegression } from 'ml-cart';\n\nconst x = new Array(100);\nconst y = new Array(100);\nconst val = 0.0;\nfor (let i = 0; i \u003c x.length; ++i) {\n  x[i] = val;\n  y[i] = Math.sin(x[i]);\n  val += 0.01;\n}\n\nconst reg = new DTRegression();\nreg.train(x, y);\nconst estimations = reg.predict(x);\n```\n\n## License\n\n[MIT](./LICENSE)\n\n[npm-image]: https://img.shields.io/npm/v/ml-cart.svg\n[npm-url]: https://npmjs.org/package/ml-cart\n[ci-image]: https://github.com/mljs/decision-tree-cart/workflows/Node.js%20CI/badge.svg?branch=master\n[ci-url]: https://github.com/mljs/decision-tree-cart/actions?query=workflow%3A%22Node.js+CI%22\n[download-image]: https://img.shields.io/npm/dm/ml-cart.svg\n[download-url]: https://npmjs.org/package/ml-cart\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmljs%2Fdecision-tree-cart","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmljs%2Fdecision-tree-cart","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmljs%2Fdecision-tree-cart/lists"}