{"id":19098446,"url":"https://github.com/winkjs/wink-regression-tree","last_synced_at":"2025-04-30T15:26:09.202Z","repository":{"id":47969139,"uuid":"102857209","full_name":"winkjs/wink-regression-tree","owner":"winkjs","description":"Decision Tree to predict the value of a continuous target variable","archived":false,"fork":false,"pushed_at":"2023-02-27T16:32:54.000Z","size":1683,"stargazers_count":16,"open_issues_count":4,"forks_count":9,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-13T02:19:02.343Z","etag":null,"topics":["continuous-variable","decision-trees","machine-learning","prediction","recursive-partitioning","regression-trees"],"latest_commit_sha":null,"homepage":"http://winkjs.org/wink-regression-tree/","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/winkjs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2017-09-08T12:04:36.000Z","updated_at":"2024-09-30T09:53:31.000Z","dependencies_parsed_at":"2023-09-23T22:33:56.501Z","dependency_job_id":null,"html_url":"https://github.com/winkjs/wink-regression-tree","commit_stats":{"total_commits":77,"total_committers":3,"mean_commits":"25.666666666666668","dds":0.2987012987012987,"last_synced_commit":"c4479ccdbae2515532d0ac9c31bb9d9a3fbbe3dd"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/winkjs%2Fwink-regression-tree","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/winkjs%2Fwink-regression-tree/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/winkjs%2Fwink-regression-tree/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/winkjs%2Fwink-regression-tree/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/winkjs","download_url":"https://codeload.github.com/winkjs/wink-regression-tree/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249517965,"owners_count":21284867,"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":["continuous-variable","decision-trees","machine-learning","prediction","recursive-partitioning","regression-trees"],"created_at":"2024-11-09T03:45:48.413Z","updated_at":"2025-04-18T16:32:20.136Z","avatar_url":"https://github.com/winkjs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# wink-regression-tree\n\nDecision Tree to predict the value of a continuous target variable\n\n### [![Build Status](https://api.travis-ci.org/winkjs/wink-regression-tree.svg?branch=master)](https://travis-ci.org/winkjs/wink-regression-tree) [![Coverage Status](https://coveralls.io/repos/github/winkjs/wink-regression-tree/badge.svg?branch=master)](https://coveralls.io/github/winkjs/wink-regression-tree?branch=master) [![Inline docs](http://inch-ci.org/github/winkjs/wink-regression-tree.svg?branch=master)](http://inch-ci.org/github/winkjs/wink-regression-tree) [![dependencies Status](https://david-dm.org/winkjs/wink-regression-tree/status.svg)](https://david-dm.org/winkjs/wink-regression-tree) [![devDependencies Status](https://david-dm.org/winkjs/wink-regression-tree/dev-status.svg)](https://david-dm.org/winkjs/wink-regression-tree?type=dev) [![Gitter](https://img.shields.io/gitter/room/nwjs/nw.js.svg)](https://gitter.im/winkjs/Lobby)\n\n\u003cimg align=\"right\" src=\"https://decisively.github.io/wink-logos/logo-title.png\" width=\"100px\" \u003e\n\nPredict the value of a continuous variable such as price, turn around time, or mileage using **`wink-regression-tree`**.\n\n\n### Installation\n\nUse [npm](https://www.npmjs.com/package/wink-regression-tree) to install:\n\n    npm install wink-regression-tree --save\n\n### Getting Started\nHere is an example of predicting car’s mileage (miles per gallon - mpg) from attributes like displacement, horsepower, acceleration, country of origin, and few more. A sample data row is given for quick reference:\n\n| Model          | MPG | Cylinders | Displacement | Power | Weight | Acceleration | Year | Origin |\n|--------------|-----|----------|------------------|----------|-----------|----|---|-----|\n|Toyota Mark II|20|6|large displacement|high power|high weight|slow|73|Japan|\n\nThe code below provides a potential configuration to predict the value of miles per gallon:\n\n```javascript\n// Load wink-regression-tree.\nvar regressionTree = require( 'wink-regression-tree' );\n\n// Load cars training data set.\n// In practice an async mechanism may be used to\n// read data asynchronously and call `ingest()` on\n// every row of data read.\nvar cars = require( 'wink-regression-tree/sample-data/cars.json' );\n\n// Create a sample data to test prediction for\n// Ford Gran Torino, having \"mpg of 14.5\", very\n// large displacement, extremely high power, very\n// high weight, slow, and with origin as US.\nvar input = {\n  model: 'Ford Gran Torino',\n  weight: 'very high weight',\n  displacement: 'very large displacement',\n  horsepower: 'extremely high power',\n  origin: 'US',\n  acceleration: 'slow'\n};\n// Above record is not the part of training data.\n\n// Create an instance of the regression  tree.\nvar rt = regressionTree();\n\n// Specify columns of the training data.\nvar columns = [\n  { name: 'model', categorical: true, exclude: true },\n  { name: 'mpg', categorical: false, target: true },\n  { name: 'cylinders', categorical: true, exclude: false },\n  { name: 'displacement', categorical: true, exclude: false },\n  { name: 'horsepower', categorical: true, exclude: false },\n  { name: 'weight', categorical: true, exclude: false },\n  { name: 'acceleration', categorical: true, exclude: false },\n  { name: 'year', categorical: true, exclude: true },\n  { name: 'origin', categorical: true, exclude: false  }\n];\n// Specify configuration for learning.\nvar treeParams = {\n  minPercentVarianceReduction: 0.5,\n  minLeafNodeItems: 10,\n  minSplitCandidateItems: 30,\n  minAvgChildrenItems: 2\n};\n// Define the regression tree configuration using\n// `columns` and `treeParams`.\nrt.defineConfig( columns, treeParams );\n\n// Ingest the data.\ncars.forEach( function ( row ) {\n  rt.ingest( row );\n} );\n\n// Data ingested! Now time to learn from data!!\nconsole.log( rt.learn() );\n// -\u003e 16 (Number of Rules Learned)\n\n// Predict the **mean** value.\nvar mean = rt.predict( input );\nconsole.log( +mean.toFixed( 1 ) );\n// -\u003e 14.3 ( compare with actual mpg of 14.5 )\n\n// In practice one may like to compute a range\n// or upper limit using the `modifier` function\n// during prediction. Note `size`, `mean`, and `stdev`\n// values, passed to this function, can be used\n// for computing the range or the upper limit.\n```\n\nTry [experimenting with this example on Runkit](https://npm.runkit.com/wink-regression-tree) in the browser.\n\n### Documentation\nFor detailed API docs, check out http://winkjs.org/wink-regression-tree/ URL!\n\n### Need Help?\n\nIf you spot a bug and the same has not yet been reported, raise a new [issue](https://github.com/winkjs/wink-regression-tree/issues) or consider fixing it and sending a pull request.\n\n### About wink\n[Wink](http://winkjs.org/) is a family of open source packages for **Statistical Analysis**, **Natural Language Processing** and **Machine Learning** in NodeJS. The code is **thoroughly documented** for easy human comprehension and has a **test coverage of ~100%** for reliability to build production grade solutions.\n\n### Copyright \u0026 License\n\n**wink-regression-tree** is copyright 2017-18 [GRAYPE Systems Private Limited](http://graype.in/).\n\nIt is licensed under the terms of the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwinkjs%2Fwink-regression-tree","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwinkjs%2Fwink-regression-tree","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwinkjs%2Fwink-regression-tree/lists"}