You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

wink-regression-tree

Package Overview
Dependencies
Maintainers
3
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wink-regression-tree - npm Package Compare versions

Comparing version

to
1.1.1

6

package.json
{
"name": "wink-regression-tree",
"version": "1.1.0",
"version": "1.1.1",
"description": "Decision Tree to predict the value of a continuous target variable",

@@ -35,3 +35,3 @@ "keywords": [

"chai": "^4.1.0",
"coveralls": "^2.11.15",
"coveralls": "^3.0.0",
"docker": "^1.0.0",

@@ -42,3 +42,3 @@ "documentation": "^5.3.1",

"jshint": "^2.9.4",
"mocha": "^3.1.0",
"mocha": "^4.0.1",
"mocha-lcov-reporter": "^1.2.0"

@@ -45,0 +45,0 @@ },

@@ -9,3 +9,3 @@ # wink-regression-tree

Predict the value of a continuous variable such as price, turn around time, or mileage using **`wink-regression-tree`**. It is a part of _[wink](https://www.npmjs.com/~sanjaya)_ — a growing family of high quality packages for Statistical Analysis, Natural Language Processing and Machine Learning in NodeJS.
Predict the value of a continuous variable such as price, turn around time, or mileage using **`wink-regression-tree`**. It is a part of _[wink](http://wink.org.in/)_ — a growing family of high quality packages for Statistical Analysis, Natural Language Processing and Machine Learning in NodeJS.

@@ -97,3 +97,3 @@

### Documentation
For detailed API docs, check out https://winkjs.github.io/wink-regression-tree/ URL!
For detailed API docs, check out http://wink.org.in/wink-regression-tree/ URL!

@@ -106,5 +106,5 @@ ### Need Help?

**wink-regression-tree** is copyright 2017 GRAYPE Systems Private Limited.
**wink-regression-tree** is copyright 2017 [GRAYPE Systems Private Limited](http://graype.in/).
It is licensed under the under the terms of the GNU Affero General Public License as published by the Free
Software Foundation, version 3 of the License.

@@ -27,2 +27,3 @@ // wink-regression-tree

var helpers = require( 'wink-helpers' );
var stdevEPSILON = Math.pow( 2, -48 );

@@ -380,4 +381,3 @@ // ### regressionTree

if ( depth > config.maxDepth ) {
// Yes, Incrment rules learned & return.
wrTree.rulesLearned += 1;
// Yes, return.
return;

@@ -397,3 +397,3 @@ }

if ( splitData[ uniqVal ].size < config.minLeafNodeItems ) {
// Don't increment rules learned as you are pruning tree; just skip this iteration.
// Just skip this iteration.
continue;

@@ -411,5 +411,4 @@ }

// Does it have enough items to proceed with split?
if ( index.length <= config.minSplitCandidateItems ) {
if ( index.length <= config.minSplitCandidateItems || child.stdev < stdevEPSILON ) {
// No! continue with the iteration with the next `uniqVal`.
wrTree.rulesLearned += 1;
continue;

@@ -424,3 +423,2 @@ }

// No best column found, coninue with the next one!
wrTree.rulesLearned += 1;
continue;

@@ -432,3 +430,2 @@ }

// No! continue with the iteration with the next `uniqVal`.
wrTree.rulesLearned += 1;
continue;

@@ -449,2 +446,21 @@ }

// ### countRules
/**
*
* Counts the number of rules generated from a rules tree and updates the final
* number in the root node of the tree.
*
* @param {object} tree — the rules tree.
* @return {undefined} or void!
* @private
*/
var countRules = function ( tree ) {
var subTree = tree.branches;
for ( var node in subTree ) {
if ( subTree[ node ].branches !== undefined && Object.keys( subTree[ node ].branches ).length > 0 ) {
countRules( subTree[ node ] );
} else wrTree.rulesLearned += 1;
}
}; // countRules()
// ### defineConfig

@@ -608,17 +624,21 @@ /**

wrTree.stdev = computeStdev( rootsVarianceXn, wrTree.size );
bestSplit = selectBestSplit( cndts );
if ( bestSplit === undefined ) {
// Opps, no worthy column available - return the root!
wrTree.rulesLearned += 1;
return true;
// Attempt to grow tree if standard deviation is large enough!
if ( wrTree.stdev > stdevEPSILON ) {
bestSplit = selectBestSplit( cndts );
if ( bestSplit === undefined ) {
// Opps, no worthy column available - return the root!
return true;
}
// Find the updated list of candidate columsn after the split.
for ( i = 0; i < candidateCols.length; i += 1 ) {
if ( candidateCols[ i ] !== bestSplit.col ) updatedCandidateCols.push( candidateCols[ i ] );
}
// Define the balance stuff as a split has been found!
wrTree.colUsed4Split = columnsDefn[xc2cMap[bestSplit.col]].name;
wrTree.varianceReduction = computePercentageVarianceReduction( rootsVarianceXn, wrTree.size, bestSplit.sum );
// Call recursive function, `growTree()`.
growTree( updatedCandidateCols, cndts.columns[ bestSplit.col ], bestSplit.col, wrTree, 1 );
}
// Find the updated list of candidate columsn after the split.
for ( i = 0; i < candidateCols.length; i += 1 ) {
if ( candidateCols[ i ] !== bestSplit.col ) updatedCandidateCols.push( candidateCols[ i ] );
}
// Define the balance stuff as a split has been found!
wrTree.colUsed4Split = columnsDefn[xc2cMap[bestSplit.col]].name;
wrTree.varianceReduction = computePercentageVarianceReduction( rootsVarianceXn, wrTree.size, bestSplit.sum );
// Call recursive function, `growTree()`.
growTree( updatedCandidateCols, cndts.columns[ bestSplit.col ], bestSplit.col, wrTree, 1 );
wrTree.rulesLearned = 0;
countRules( wrTree );
return wrTree.rulesLearned;

@@ -625,0 +645,0 @@ }; // learn()