MCPcopy Create free account
hub / github.com/EdwardRaff/JSAT / makeNodeC

Method makeNodeC

JSAT/src/jsat/classifiers/trees/DecisionTree.java:381–424  ·  view source on GitHub ↗

Makes a new node for classification @param dataPoints the list of data points paired with their class @param options the attributes that this tree may select from @param depth the current depth of the tree @param threadPool the source of threads @param mcdl count down latch @return the node created,

(List<DataPointPair<Integer>> dataPoints, final Set<Integer> options, final int depth,
            final ExecutorService threadPool, final ModifiableCountDownLatch mcdl)

Source from the content-addressed store, hash-verified

379 * @return the node created, or null if no node was created
380 */
381 protected Node makeNodeC(List<DataPointPair<Integer>> dataPoints, final Set<Integer> options, final int depth,
382 final ExecutorService threadPool, final ModifiableCountDownLatch mcdl)
383 {
384 //figure out what level of parallelism we are going to use, feature wise or depth wise
385 boolean mePara = (1L<<depth) < SystemInfo.LogicalCores*2;//should THIS node use the Stump parallelism
386 boolean depthPara = (1L<<(depth+1)) >= SystemInfo.LogicalCores*2;//should the NEXT node use the stump parallelism
387
388 if(depth > maxDepth || options.isEmpty() || dataPoints.size() < minSamples || dataPoints.isEmpty())
389 {
390 mcdl.countDown();
391 return null;
392 }
393 DecisionStump stump = baseStump.clone();
394 stump.setPredicting(this.predicting);
395 final List<List<DataPointPair<Integer>>> splits;
396 if(mePara)
397 splits = stump.trainC(dataPoints, options, threadPool);
398 else
399 splits = stump.trainC(dataPoints, options);
400
401 final Node node = new Node(stump);
402 if(stump.getNumberOfPaths() > 1)//If there is 1 path, we are perfectly classifier - nothing more to do
403 for(int i = 0; i < node.paths.length; i++)
404 {
405 final int ii = i;
406 final List<DataPointPair<Integer>> splitI = splits.get(i);
407 mcdl.countUp();
408 if(depthPara)
409 {
410 threadPool.submit(new Runnable() {
411
412 public void run()
413 {
414 node.paths[ii] = makeNodeC(splitI, new IntSet(options), depth+1, threadPool, mcdl);
415 }
416 });
417 }
418 else
419 node.paths[ii] = makeNodeC(splitI, new IntSet(options), depth+1, threadPool, mcdl);
420 }
421
422 mcdl.countDown();
423 return node;
424 }
425
426 /**
427 * Makes a new node for regression

Callers 2

trainCMethod · 0.95
runMethod · 0.95

Calls 9

setPredictingMethod · 0.95
trainCMethod · 0.95
getNumberOfPathsMethod · 0.95
countDownMethod · 0.80
countUpMethod · 0.80
submitMethod · 0.80
sizeMethod · 0.65
cloneMethod · 0.65
getMethod · 0.45

Tested by

no test coverage detected