public virtual XmlElement CreateXml(XmlDocument doc)
        {
            XmlElement node_element = doc.CreateElement("DecisionTreeNode");

            node_element.AppendAttribute("SplitVariableName", mSplitVariableName);
            node_element.AppendAttribute("VariableName", mVariableName);
            node_element.AppendAttribute("VariableValue", mVariableValue);
            node_element.AppendAttribute("InformationGain", mInformationGain);
            node_element.AppendAttribute("RecordCount", mRecordCount);

            XmlElement class_variable_value_distribution_element = doc.CreateElement("ClassVariableValueDistribution");

            node_element.AppendChild(class_variable_value_distribution_element);
            foreach (string class_variable_value in mClassVariableValueDistribution.Keys)
            {
                XmlElement class_variable_value_element = doc.CreateElement("ClassVariableValue");
                class_variable_value_distribution_element.AppendAttribute("RecordCount", mClassVariableValueDistribution[class_variable_value]);
                class_variable_value_distribution_element.AppendAttribute("VariableValue", class_variable_value);
                class_variable_value_distribution_element.AppendChild(class_variable_value_element);
            }

            XmlElement child_nodes_element = doc.CreateElement("ChildNodes");

            node_element.AppendChild(child_nodes_element);
            foreach (string split_variable_value in mChildren.Keys)
            {
                DecisionTreeNode <T> child_node         = mChildren[split_variable_value];
                XmlElement           child_node_element = child_node.CreateXml(doc);
                child_nodes_element.AppendChild(child_node_element);
            }

            return(node_element);
        }
Пример #2
0
        public XmlDocument CreateXml()
        {
            XmlDocument doc      = new XmlDocument();
            XmlElement  xml_root = doc.CreateElement("DecisionTree");

            XmlElement root_node_element = mRootNode.CreateXml(doc);

            xml_root.AppendChild(root_node_element);

            doc.AppendChild(xml_root);
            return(doc);
        }