コード例 #1
0
ファイル: Pmml.cs プロジェクト: wearefullstack/pmml4net
        /// <summary>
        /// Load pmml file
        /// </summary>
        /// <param name="xml">Xml PMML file to read></param>
        public static Pmml loadModels(XmlDocument xml)
        {
            Pmml pmml = new Pmml();

            pmml.models = new List <ModelElement>();

            foreach (XmlNode root in xml.ChildNodes)
            {
                if (root is XmlElement)
                {
                    foreach (XmlNode child in root.ChildNodes)
                    {
                        if (child.Name.Equals("DataDictionary"))
                        {
                            pmml.DataDictionary = DataDictionary.loadFromXmlNode(child);
                        }
                        else if (child.Name.Equals("RuleSetModel"))
                        {
                            pmml.models.Add(RuleSetModel.loadFromXmlNode(child));
                        }
                        else if (child.Name.Equals("TreeModel"))
                        {
                            pmml.models.Add(TreeModel.loadFromXmlNode(child));
                        }
                        else if (child.Name.Equals("MiningModel"))
                        {
                            pmml.models.Add(MiningModel.loadFromXmlNode(child));
                        }
                    }
                }
            }

            return(pmml);
        }
コード例 #2
0
        /// <summary>
        /// Load tree model from xmlnode
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        public static RuleSetModel loadFromXmlNode(XmlNode node)
        {
            string functionName = null;

            if (node.Attributes["functionName"] != null)
            {
                functionName = node.Attributes["functionName"].Value;
            }

            RuleSetModel model = new RuleSetModel(MiningFunctionFromString(functionName));

            model.ModelName = node.Attributes["modelName"].Value;

            /*if (node.Attributes["missingValueStrategy"] != null)
             *      tree.MissingValueStrategy = MissingValueStrategyfromString(node.Attributes["missingValueStrategy"].Value);
             *
             * // By default noTrueChildStrategy = returnNullPrediction
             * tree.noTrueChildStrategy = NoTrueChildStrategy.ReturnNullPrediction;
             * if (node.Attributes["noTrueChildStrategy"] != null)
             *      tree.noTrueChildStrategy = NoTrueChildStrategyfromString(node.Attributes["noTrueChildStrategy"].Value);*/


            foreach (XmlNode item in node.ChildNodes)
            {
                if ("extension".Equals(item.Name.ToLowerInvariant()))
                {
                    // TODO : implement extension
                    //root.Nodes.Add(Node.loadFromXmlNode(item));
                }
                else if ("MiningSchema".Equals(item.Name))
                {
                    model.MiningSchema = MiningSchema.loadFromXmlNode(item);
                }
                else if ("RuleSet".Equals(item.Name))
                {
                    model.RuleSet = RuleSet.loadFromXmlNode(item);
                }
                else
                {
                    throw new NotImplementedException();
                }
            }

            return(model);
        }
コード例 #3
0
ファイル: RuleSetModel.cs プロジェクト: mindis/pmml4net
        /// <summary>
        /// Load tree model from xmlnode
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        public static RuleSetModel loadFromXmlNode(XmlNode node)
        {
            string functionName = null;
            if (node.Attributes["functionName"] != null)
                functionName = node.Attributes["functionName"].Value;

            RuleSetModel model = new RuleSetModel(MiningFunctionFromString(functionName));

            model.ModelName = node.Attributes["modelName"].Value;

            /*if (node.Attributes["missingValueStrategy"] != null)
                tree.MissingValueStrategy = MissingValueStrategyfromString(node.Attributes["missingValueStrategy"].Value);

            // By default noTrueChildStrategy = returnNullPrediction
            tree.noTrueChildStrategy = NoTrueChildStrategy.ReturnNullPrediction;
            if (node.Attributes["noTrueChildStrategy"] != null)
                tree.noTrueChildStrategy = NoTrueChildStrategyfromString(node.Attributes["noTrueChildStrategy"].Value);*/

            foreach(XmlNode item in node.ChildNodes)
            {
                if ("extension".Equals(item.Name.ToLowerInvariant()))
                {
                    // TODO : implement extension
                    //root.Nodes.Add(Node.loadFromXmlNode(item));
                }
                else if ("MiningSchema".Equals(item.Name))
                {
                    model.MiningSchema = MiningSchema.loadFromXmlNode(item);
                }
                else if ("RuleSet".Equals(item.Name))
                {
                    model.RuleSet = RuleSet.loadFromXmlNode(item);
                }
                else
                    throw new NotImplementedException();
            }

            return model;
        }