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

Method makeNodeR

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

Makes a new node for regression @param dataPoints the list of data points paired with their associated real value @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 n

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

Source from the content-addressed store, hash-verified

433 * @return the node created, or null if no node was created
434 */
435 protected Node makeNodeR(List<DataPointPair<Double>> dataPoints, final Set<Integer> options, final int depth,
436 final ExecutorService threadPool, final ModifiableCountDownLatch mcdl)
437 {
438 //figure out what level of parallelism we are going to use, feature wise or depth wise
439 boolean mePara = (1L<<depth) < SystemInfo.LogicalCores*2;//should THIS node use the Stump parallelism
440 boolean depthPara = (1L<<(depth+1)) >= SystemInfo.LogicalCores*2;//should the NEXT node use the stump parallelism
441
442 if(depth > maxDepth || options.isEmpty() || dataPoints.size() < minSamples || dataPoints.isEmpty())
443 {
444 mcdl.countDown();
445 return null;
446 }
447 DecisionStump stump = baseStump.clone();
448 final List<List<DataPointPair<Double>>> splits;
449 if(mePara)
450 splits = stump.trainR(dataPoints, options, threadPool);
451 else
452 splits = stump.trainR(dataPoints, options);
453 if(splits == null)//an error occured, probably not enough data for many categorical values
454 {
455 mcdl.countDown();
456 return null;
457 }
458
459 final Node node = new Node(stump);
460 if(stump.getNumberOfPaths() > 1)//If there is 1 path, we are perfectly classifier - nothing more to do
461 for(int i = 0; i < node.paths.length; i++)
462 {
463 final int ii = i;
464 final List<DataPointPair<Double>> splitI = splits.get(i);
465 mcdl.countUp();
466 if(depthPara)
467 {
468 threadPool.submit(new Runnable() {
469
470 @Override
471 public void run()
472 {
473 node.paths[ii] = makeNodeR(splitI, new IntSet(options), depth+1, threadPool, mcdl);
474 }
475 });
476 }
477 else
478 node.paths[ii] = makeNodeR(splitI, new IntSet(options), depth+1, threadPool, mcdl);
479 }
480
481 mcdl.countDown();
482 return node;
483 }
484
485 @Override
486 public void trainC(ClassificationDataSet dataSet)

Callers 2

trainMethod · 0.95
runMethod · 0.95

Calls 8

trainRMethod · 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