use of com.alibaba.alink.operator.common.tree.Node in project Alink by alibaba.
the class TreeObj method initialRoot.
public final void initialRoot() {
for (int i = 0; i < numTrees; ++i) {
Node root = TreeObj.ofNode();
addNodeInfoPair(ofNodeInfoPair(root, -1, null).initialRoot(i * numLocalBaggingRow, (i + 1) * numLocalBaggingRow));
roots.add(root);
}
}
use of com.alibaba.alink.operator.common.tree.Node in project Alink by alibaba.
the class SplitInstances method split.
public static NodeInfoPair split(NodeInfoPair.NodeInfo nodeInfo, EpsilonApproQuantile.WQSummary summary, int[] indices, Data data) {
int mid = data.splitInstances(nodeInfo.node, summary, indices, nodeInfo.slice);
int oobMid = data.splitInstances(nodeInfo.node, summary, indices, nodeInfo.oob);
nodeInfo.node.setNextNodes(new Node[] { new Node(), new Node() });
return new NodeInfoPair(// left
new NodeInfoPair.NodeInfo(nodeInfo.node.getNextNodes()[0], new Slice(nodeInfo.slice.start, mid), new Slice(nodeInfo.oob.start, oobMid), nodeInfo.depth + 1, nodeInfo.baggingFeatures), // right
new NodeInfoPair.NodeInfo(nodeInfo.node.getNextNodes()[1], new Slice(mid, nodeInfo.slice.end), new Slice(oobMid, nodeInfo.oob.end), nodeInfo.depth + 1, null));
}
use of com.alibaba.alink.operator.common.tree.Node in project Alink by alibaba.
the class IForestsModelMapper method predictResultDetail.
@Override
protected Tuple2<Object, String> predictResultDetail(SlicedSelectedSample selection) throws Exception {
Node[] root = treeModel.roots;
Row inputBuffer = inputBufferThreadLocal.get();
selection.fillRow(inputBuffer);
transform(inputBuffer);
int len = root.length;
Object result = null;
if (len > 0) {
double hSum = 0.0;
for (Node node : root) {
hSum += predict(inputBuffer, node, 1);
}
result = s(hSum / len, totalC);
}
return new Tuple2<>(result, null);
}
use of com.alibaba.alink.operator.common.tree.Node in project Alink by alibaba.
the class NodeJPanel method multiNodeDistribution.
public static double multiNodeDistribution(TreeModelViz.Node4CalcPos node4CalcPos) {
double multi = 1.0;
Node node = node4CalcPos.node;
if (node.getCounter().getDistributions() == null || node.getCounter().getDistributions().length < 1) {
return 0.0;
}
if (node.isLeaf()) {
for (int j = 0; j < node.getCounter().getDistributions().length; ++j) {
multi *= node.getCounter().getDistributions()[j];
}
} else {
if (node.getCounter().getWeightSum() == 0.0) {
return 0.0;
}
for (int j = 0; j < node.getCounter().getDistributions().length; ++j) {
multi *= node.getCounter().getDistributions()[j] / node.getCounter().getWeightSum();
}
}
return multi;
}
Aggregations