var predicates = { // '==': function (a, b) { return a == b }, // , : // ( == ""), // - // '>=': function (a, b) { return a >= b } // , : // , 18 ( >= 18), // - };
Character | Hair Length (inches) | Weight (pounds) | Age | Floor |
Homer | 0 | 250 | 36 | M |
Marge | ten | 150 | 34 | F |
Bart | 2 | 90 | ten | M |
Liza | 6 | 78 | eight | F |
Maggie | four | 20 | one | F |
Abe | one | 170 | 70 | M |
Selma | eight | 160 | 41 | F |
Otto | ten | 180 | 38 | M |
Krusty | 6 | 200 | 45 | M |
var data = [{person: 'Homer', hairLength: 0, weight: 250, age: 36, sex: 'male'}, {person: 'Marge', hairLength: 10, weight: 150, age: 34, sex: 'female'}, {person: 'Bart', hairLength: 2, weight: 90, age: 10, sex: 'male'}, {person: 'Lisa', hairLength: 6, weight: 78, age: 8, sex: 'female'}, {person: 'Maggie', hairLength: 4, weight: 20, age: 1, sex: 'female'}, {person: 'Abe', hairLength: 1, weight: 170, age: 70, sex: 'male'}, {person: 'Selma', hairLength: 8, weight: 160, age: 41, sex: 'female'}, {person: 'Otto', hairLength: 10, weight: 180, age: 38, sex: 'male'}, {person: 'Krusty', hairLength: 6, weight: 200, age: 45, sex: 'male'}];
var config = { // trainingSet: data, // , , categoryAttr: 'sex', // , ignoredAttributes: ['person'] // , : // // maxTreeDepth: 10 // , // entropyThrehold: 0.05 // , // minItemsCount: 3 }; // : var decisionTree = new dt.DecisionTree(config); // : var numberOfTrees = 3; var randomForest = new dt.RandomForest(config, numberOfTrees);
var comic = {person: 'Comic guy', hairLength: 8, weight: 290, age: 38}; var decisionTreePrediction = decisionTree.predict(comic); // // , var randomForestPrediction = randomForest.predict(comic); // // , , // - , "" , // // // - - , // ,
Source: https://habr.com/ru/post/208952/
All Articles