Пример #1
0
        private void PlotLearningCurve(Testing.CurvePoint[] learningCurve, out GraphForm graphFormS, out GraphForm graphFormFn, out GraphForm graphFormFp, double[] simpleAlgorithm, bool excludeLearnedFromTestingSet)
        {
            // Create 3 new graphs
               GraphForm.GraphPlot graphSuccess = new GraphForm.GraphPlot("TrainingSet", "Success");
               GraphForm.GraphPlot graphFN = new GraphForm.GraphPlot("TrainingSet", "False Negative");
               GraphForm.GraphPlot graphFP = new GraphForm.GraphPlot("TrainingSet", "False Positive");
               graphSuccess.setUsedForLearningCurve(true);
               graphFN.setUsedForLearningCurve(true);
               graphFP.setUsedForLearningCurve(true);

               // add point (0,0)
               graphSuccess.addPoint(0, 0, "", Color.Black);
               graphFN.addPoint(0, 0, "", Color.Black);
               graphFP.addPoint(0, 0, "", Color.Black);
               foreach (Testing.CurvePoint p in learningCurve)
               {
               graphSuccess.addPoint(p.getTrainingSetPercentage(), p.getAvgPercentageCorrect(), Math.Round(p.getStdPercentageCorrect(), 2).ToString(), Color.Black);
               graphFN.addPoint(p.getTrainingSetPercentage(), p.getAvgPercentageFalseNegative(), Math.Round(p.getStdPercentageFalseNegative(), 2).ToString(), Color.Black);
               graphFP.addPoint(p.getTrainingSetPercentage(), p.getAvgPercentageFalsePositive(), Math.Round(p.getStdPercentageFalsePositive(), 2).ToString(), Color.Black);
               }
               // add point (100,100) or (100,0)
               graphSuccess.addPoint(100, 100, "", Color.Black);
               graphFN.addPoint(100, 0, "", Color.Black);
               graphFP.addPoint(100, 0, "", Color.Black);

               //add comparison line for statistical simple algorithms
               string partially = (excludeLearnedFromTestingSet) ? "" : "partially_statistical";
               graphSuccess.addComparisonLines(simpleAlgorithm[0], "statistical", partially);
               graphFN.addComparisonLines(simpleAlgorithm[1], "statistical", partially);
               graphFP.addComparisonLines(simpleAlgorithm[2], "statistical", partially);

               // Draw
               graphFormS = new GraphForm(graphSuccess);
               graphFormFn = new GraphForm(graphFN);
               graphFormFp = new GraphForm(graphFP);
               graphFormS.Show();
               graphFormFn.Show();
               graphFormFp.Show();
        }
Пример #2
0
        private void threadTestParameterClassification()
        {
            // Get folders
            string folderTrue = txtFolderTrueTesting2.Text;
            string folderFalse = txtFolderFalseTesting2.Text;

            // Get wanted parameters
            int parXindex = Convert.ToInt16(txtParamXTesting2.Text);
            int parYindex = Convert.ToInt16(txtParamYTesting2.Text);

            // Get wanted colors
            Color cTrue = pboxColorTrueTesting2.BackColor;
            Color cFalse = pboxColorFalseTesting2.BackColor;

            // Construct graph
            GraphForm.GraphPlot graph = Testing.makeGraph(folderTrue, folderFalse, parXindex, parYindex, cTrue, cFalse);

            _graph = graph;
        }
Пример #3
0
        /* Making classification graphs for given photos */
        public static GraphForm.GraphPlot makeGraph(string folderTruePath, string folderFalsePath, int parX, int parY, Color cTrue, Color cFalse)
        {
            _progress = 0;

            // Get list of files in the folderer (assuming all are images)
            string[] filesTrue = LoadImages(folderTruePath);
            string[] filesFalse = LoadImages(folderFalsePath);
            int numOfFiles = filesTrue.Length + filesFalse.Length;
            int filesProcessed = 0;

            // Build dictionary for wanted parameters
            Dictionary<ImageVector.ImageParameters, bool> parameters = new Dictionary<ImageVector.ImageParameters, bool>();
            parameters.Add(ImageVector.getParameterNameByIndex(parX), true);
            parameters.Add(ImageVector.getParameterNameByIndex(parY), true);
            for (int i = 0; i < ImageVector.NUMBER_OF_PARAMETERS; i++)
                if (!parameters.ContainsKey(ImageVector.getParameterNameByIndex(i)))
                    parameters.Add(ImageVector.getParameterNameByIndex(i), false);

            // Convert images to vectors
            List<ImageVector> trueList = new List<ImageVector>();
            List<ImageVector> falseList = new List<ImageVector>();
            foreach (string picPath in filesTrue)
            {
                trueList.Add(new ImageVector(picPath, parameters));
                filesProcessed++;
                Progress = (int)((filesProcessed / numOfFiles) * 100);
            }
            foreach (string picPath in filesFalse)
            {
                falseList.Add(new ImageVector(picPath, parameters));
                filesProcessed++;
                Progress = (int)((filesProcessed / numOfFiles) * 100);
            }

            // Construct graph
            string par1name = ImageVector.getParameterNameByIndex(parX).ToString();
            string par2name = ImageVector.getParameterNameByIndex(parY).ToString();
            GraphForm.GraphPlot graph = new GraphForm.GraphPlot(par1name, par2name);

            // Add points to graph
            double valueX, valueY;
            for (int i = 0; i < trueList.Count; i++)
            {
                valueX = trueList[i].getParameterByIndex(parX);
                valueY = trueList[i].getParameterByIndex(parY);
                graph.addPoint(valueX, valueY, i.ToString(), cTrue);
            }
            for (int i = 0; i < falseList.Count; i++)
            {
                valueX = falseList[i].getParameterByIndex(parX);
                valueY = falseList[i].getParameterByIndex(parY);
                graph.addPoint(valueX, valueY, i.ToString(), cFalse);
            }

            // Get classifications from classifier class
            double[] boundsX = new double[0];
            double[] boundsY = new double[0];
            Classifier.getBoundArray(ImageVector.getParameterNameByIndex(parX), ref boundsX);
            Classifier.getBoundArray(ImageVector.getParameterNameByIndex(parY), ref boundsY);

            // Convert bounds array to list object and create classification representing char lists
            List<double> bX = new List<double>();
            List<double> bY = new List<double>();
            List<string> bXnames = new List<string>();
            List<string> bYnames = new List<string>();
            int chr_a = 97;
            for (int i = 0; i < boundsX.Length; i++)
            {
                bX.Add(boundsX[i]);
                bXnames.Add(Convert.ToChar(chr_a + i).ToString());
            }
            bXnames.Add(Convert.ToChar(chr_a + boundsX.Length).ToString());
            for (int i = 0; i < boundsY.Length; i++)
            {
                bY.Add(boundsY[i]);
                bYnames.Add(Convert.ToChar(chr_a + i).ToString());
            }
            bYnames.Add(Convert.ToChar(chr_a + boundsY.Length).ToString());

            // Add classification to graph
            graph.addXClassification(bX, bXnames);
            graph.addYClassification(bY, bYnames);

            return graph;
        }