コード例 #1
0
        private void PreprocessToWorkTree()
        {
            var c45         = new DecisionTreeC45();
            int parameterID = XMLWork.FindIDWithName(parameterCondition.SelectedItem.ToString(), Properties.Settings.Default.Languages);

            _root = c45.MountTree(TrainData.Train, TrainData.nameParameter, parameterID, Convert.ToInt32(textEdit1.Value) + 1);
            MessageBox.Show(Localization.MyStrings.Over);
        }
コード例 #2
0
 private void PrintNode(DM.DecisionTree.TreeNode test_tree, List <IndexVertex> vertex, int index)
 {
     if (test_tree.attribute.values != null)
     {
         for (int i = 0; i < test_tree.attribute.values.Count; i++)
         {
             TreeNode childNode = test_tree.getChildByBranchName(test_tree.attribute.values[i]);
             vertex.Add(new IndexVertex(childNode.attributeName + "\n" + childNode.Positive + "|" + childNode.Negative, index, test_tree.attribute.values[i], Brushes.DarkGreen));
             int number = vertex.Count;
             PrintNode(childNode, vertex, number - 1);
         }
     }
 }
コード例 #3
0
 private void PrintNode_group(DM.DecisionTree.TreeNode test_tree, List <IndexVertex> vertex, int index, string groupParamName)
 {
     if (test_tree.attribute.values != null)
     {
         for (int i = 0; i < test_tree.attribute.values.Count; i++)
         {
             TreeNode childNode = test_tree.getChildByBranchName(test_tree.attribute.values[i]);
             if (childNode.attributeName != groupParamName)
             {
                 vertex.Add(new IndexVertex(XMLWork.FindNameWithScada(test_tree.attributeName, language) + "\n" + childNode.Positive + "|" + childNode.Negative, index, test_tree.attribute.values[i], Brushes.DarkOrange));
                 int number = vertex.Count;
                 PrintNode_group(childNode, vertex, number - 1, groupParamName);
             }
         }
     }
 }
コード例 #4
0
        private void PreprocessToWorkTreeRandomForest(TrainData trainedData, TrainData checkData,
                                                      Dictionary <int, string> analysParameter)
        {
            int numberOfForest = Convert.ToInt32(numberOfForests.Value);

            RandForests = new List <DM.DecisionTree.TreeNode>();
            //double accuracy = 0.0;
            //do
            //{
            //Random rand = new Random((int) (DateTime.Now.Ticks));
            //DivideSet(rand, trainData, trainedData, checkData);
            List <DM.DecisionTree.TreeNode> rndForests = new List <DM.DecisionTree.TreeNode>();
            int parameterID = XMLWork.FindIDWithName(parameterCondition.SelectedItem.ToString(), Properties.Settings.Default.Languages);
            int restrictCountOfParameters          = Convert.ToInt32(Math.Sqrt(analysParameter.Count)) + 1;
            Dictionary <int, string> newParameters = new Dictionary <int, string>();


            for (int forestsCount = 0; forestsCount < numberOfForest;)
            {
                DM.DecisionTree.RandomForest random = new RandomForest();
                List <int> parametersName           = new List <int>();
                foreach (KeyValuePair <int, string> keyValuePair in analysParameter)
                {
                    if (!keyValuePair.Value.StartsWith("Def"))
                    {
                        parametersName.Add(keyValuePair.Key);
                    }
                }
                for (int i = 0; i < restrictCountOfParameters; i++)
                {
                    int j = rand.Next(0, analysParameter.Count);
                    if (!newParameters.ContainsKey(parametersName[j]))
                    {
                        newParameters.Add(parametersName[j], analysParameter[parametersName[j]]);
                    }
                }
                List <OneRow> trainData = new List <OneRow>();
                trainData = GetRandomData(TrainData.Train, newParameters, parameterID);
                _root     = random.MountTree(trainData, newParameters, parameterID, Convert.ToInt32(textEdit1.Value) + 1);
                if (_root.attributeName != "False")
                {
                    RandForests.Add(_root);
                    forestsCount++;
                }
                newParameters.Clear();
            }
        }
コード例 #5
0
        private void histogramm_Click(object sender, EventArgs e)
        {
            try
            {
                if (RandForests == null)
                {
                    ListRandomForests rndForests2 =
                        SaveXML.DeserializeObjectRandomForests(Directory.GetCurrentDirectory() + @"\" + "output2.txt");
                    RandForests = rndForests2.RndForests;
                }
                _root = rndForests[0];
                Diagramm diag = new Diagramm(RandForests);
                diag.Show();
            }
            catch (FileNotFoundException)
            {
                MessageBox.Show(Localization.MyStrings.FileNotFoundMathematical);
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }