public DTNode(DTNode node) { this.nodeGT = node.nodeGT; this.nodeId = node.nodeId; this.nodeLTE = node.nodeLTE; this.nodeType = node.nodeType; this.splitFeature = node.splitFeature; this.splitFeatureIdx = node.splitFeatureIdx; this.threshold = node.threshold; this.fIsThresholdInt = node.fIsThresholdInt; this.value = node.value; }
public DTNode[,][] CreateDTNodes(string[] ColumnNames, int cIter) { int cClasses = this.boostTreeLoss.NumTreesPerIteration; int cTrees = this.regressionTrees.Length; cIter = (cTrees / cClasses) < cIter ? (cTrees / cClasses) : cIter; DTNode[,][] nodes = new DTNode[cIter, cClasses][]; for (int i = 0; i < cIter; i++) { for (int j = 0; j < cClasses; j++) { if (this.regressionTrees[i, j] != null) { nodes[i, j] = this.regressionTrees[i, j].CreateDTNodes(this.featureNames); } } } return nodes; }
// REVIEW: CJCB public InputLayer(DTNode[,][] boostedDTs, int cIter) { int cClass = boostedDTs.GetLength(1); this.cTransforms = cIter * cClass; this.inputTransforms = new InputTransform[this.cTransforms]; this.outputs = new float[this.cTransforms]; for (int i = 0; i < cIter; i++) { for (int j = 0; j < cClass; j++) { this.inputTransforms[i*cClass + j] = new InputTransform(boostedDTs[i, j], i + 1); } } }
public InputLayer(InputLayer inLayer, DTNode[,][] boostedDTs, int cIter) { this.cTransforms = inLayer.cTransforms + cIter; this.inputTransforms = new InputTransform[this.cTransforms]; this.outputs = new float[this.cTransforms]; for (int i = 0; i < this.cTransforms; i++) { if (i < inLayer.cTransforms) { this.inputTransforms[i] = new InputTransform(inLayer.inputTransforms[i]); } else { int iNew = i - inLayer.cTransforms; this.inputTransforms[i] = new InputTransform(boostedDTs[iNew, 0], i + 1); } } }
private DTNode GetNode(int nodeId, List<DTNode> listDTNode) { foreach (DTNode node in listDTNode) { if (node.NodeID == nodeId) { return node; } } DTNode nodeNew = new DTNode(nodeId); listDTNode.Add(nodeNew); return nodeNew; }
public DecisionTreeTransform(DTNode[] dtNodes) { this.listDTNode = new List<DTNode>(dtNodes.Length); for(int i=0; i<dtNodes.Length; i++) { this.listDTNode.Add(dtNodes[i]); } }
public NNModelMSN(NNModelMSN subModel, DTNode[,][] boostedDTs) { int cIter = boostedDTs.GetLength(0); int cClass = boostedDTs.GetLength(1); if (cClass == 1) { if (subModel != null) { this.cNodeLayer = subModel.cNodeLayer; this.cInputs = subModel.cInputs + cIter; this.layers = new Layer[this.cNodeLayer + 1]; //create the input layer this.layers[0] = new InputLayer((InputLayer)subModel.layers[0], boostedDTs, cIter); //create the extended node layers for (int l = 1; l <= this.cNodeLayer; l++) { this.layers[l] = new NodeLayer((NodeLayer)subModel.layers[l], this.layers[l - 1]); } } else { this.cNodeLayer = 1; this.cInputs = cIter; this.layers = new Layer[this.cNodeLayer + 1]; this.layers[0] = new InputLayer(boostedDTs, cIter); this.layers[1] = new NodeLayer(1, this.cInputs, 1); } //add a new layer if necessary if (this.layers[this.cNodeLayer].cOutputs > 1) { this.cNodeLayer++; Layer[] layers = new Layer[this.cNodeLayer]; for (int i = 0; i < this.layers.Length; i++) { layers[i] = this.layers[i]; } this.layers = layers; this.layers[this.cNodeLayer-1] = new NodeLayer(this.cNodeLayer, this.layers[this.cNodeLayer-2].cOutputs, 1); } } else { if (subModel == null) { this.cNodeLayer = 2; this.cInputs = cIter * cClass; this.layers = new Layer[this.cNodeLayer + 1]; this.layers[0] = new InputLayer(boostedDTs, cIter); this.layers[1] = new NodeLayer(1, this.cInputs, cClass);//multiplex layer this.layers[2] = new NodeLayer(2, cClass); //dotproduct node layer } else { throw new Exception("Multiclass sub-mart has not been implemented yet"); } } }
public InputTransform(DTNode[] dtNodes, int inID) { this.ftrName = "AnchorMostFrequent"; this.funcName = "DecisionTree"; this.inputID = inID; this.transformFunc = new DecisionTreeTransform(dtNodes); }
public DTNode CreateDTNode(int iNode, string[] ColumnNames) { DTNode node = new DTNode(iNode); if (!isTerminal) { node.Add("NodeType", "Branch"); node.Add("NodeDecision", ColumnNames[this.split]); node.Add("NodeThreshold", this.splitValue.ToString()); node.Add("NodeLTE", this.leftChild.ToString()); node.Add("NodeGT", this.rightChild.ToString()); } else { node.Add("NodeType", "Value"); node.Add("NodeValue", this.regionValue.ToString()); } return node; }
public DTNode[] CreateDTNodes(string[] ColumnNames) { int cNodes = tree.Length; DTNode[] dtNodes = new DTNode[cNodes]; for (int iNode = 0; iNode < cNodes; iNode++) { if (this.tree[iNode] != null) { dtNodes[iNode] = tree[iNode].CreateDTNode(iNode, ColumnNames); } } return dtNodes; }