ML之RF:利用Js语言设计随机森林算法【DT之CART算法(gain index)】&并应用随机森林算法

ML之RF:利用Js语言设计随机森林算法【DT之CART算法(gain index)】&并应用随机森林算法


输出结果

设计思路

代码实现(部分代码)

var doTest = function() {
    option = {};
    option.treeNumber = 100;
    option.bagNumber = g.samples.length*0.80;
    option.depth = 8;
    option.bestSelect = 10;              

    var forest = createForest(g.samples, option);  

    var result = {};
    for(var x = -23; x <= 23; x += 1) {
      for(var y = -23; y <= 23; y += 1) {
          var sample = [x/10, y/10];
          var pred = predWithForest(forest, sample);
          result[x/10 + ',' + y/10] = pred;
      }
    }
    return result;
}
(0)

相关推荐