Пример #1
0
        public bool Decide()
        {
            // Get list of files in folders
            //String[] files = Testing.GetFilesFromDirectory(decidePath).ToArray();
            string csvPath = userPath + "SVM\\Decide.txt";
            string resultPath = userPath + "SVM\\Result.txt";

            // Get list of files in folders
            string[] filesAll = Testing.GetFilesFromDirectory(allPath).ToArray();
            string[] filesTrue = Testing.GetFilesFromDirectory(truePath).ToArray();
            if (filesAll.Length <= 0 || filesTrue.Length <= 0)
                return false;

            // Make False vector list - All the files in all that are not in true.

            string[] filesFalse = DataConverter.Internal_ExtractFalseFiles(filesAll, filesTrue);

            Console.WriteLine("Process good images: " + string.Format("{0:HH:mm:ss tt}", DateTime.Now));
            ImageVector[] goodImages = Internal_GetImages(filesTrue);
            Console.WriteLine("Process bad images: " + string.Format("{0:HH:mm:ss tt}", DateTime.Now));
            ImageVector[] badImages = Internal_GetImages(filesFalse);

            learningAlgo.Decide();

            LearningAlgorithmML.Algorithm[] filesTrueResults = new LearningAlgorithmML.Algorithm[filesTrue.Length];
            LearningAlgorithmML.Algorithm[] filesFalseResults = new LearningAlgorithmML.Algorithm[filesFalse.Length];

            // let the algorithm decide for each good image if it's is good or bad
            Console.WriteLine("deciding on good images Time: " + string.Format("{0:HH:mm:ss tt}", DateTime.Now));
            for (int i = 0; i < filesTrue.Length; i++)
            {
                //filesTrueResults[i] = Internal_DecideImage(goodImages[i]);
                //if(filesTrueResults[i] == learningAlgo.Algo)
                //{
                //    string[] path = goodImages[i].Path.Split('\\');
                //    string fileName = path[path.Length - 1];
                //    File.Copy(goodImages[i].Path, decidePath + "\\" + fileName);
                //}
            }

            // let the algorithm decide for each bad image if it's good or bad
            Console.WriteLine("deciding on bad images Time: " + string.Format("{0:HH:mm:ss tt}", DateTime.Now));
            for (int i = 0; i < filesFalse.Length; i++)
            {
                //filesFalseResults[i] = Internal_DecideImage(badImages[i]);
                //if (filesFalseResults[i] == learningAlgo.Algo)
                //{
                //    string[] path = goodImages[i].Path.Split('\\');
                //    string fileName = path[path.Length - 1];
                //    File.Copy(goodImages[i].Path, decidePath + "\\" + fileName);
                //}
            }

            // analyze the results
            Console.WriteLine("Analyzing the results Time: " + string.Format("{0:HH:mm:ss tt}", DateTime.Now));
            learningAlgo.checkDecision();

            learningAlgo.Quit();
            return true;
        }
Пример #2
0
        public override void restartTest()
        {
            svm.restartTest();
            knn.restartTest();

            recall = 0;
            precision = 0;
            accuracy = 0;
            acc = 0;
            FScore = 0;
            goodMeasure = 0;

            Svmrecall = 0;
            Svmprecision = 0;
            Svmaccuracy = 0;
            Svmacc = 0;
            SvmFScore = 0;
            SvmgoodMeasure = 0;

            Knnrecall = 0;
            Knnprecision = 0;
            Knnaccuracy = 0;
            Knnacc = 0;
            KnnFScore = 0;
            KnngoodMeasure = 0;

            decisionCount = 0;
            trueAndSelected = 0;
            trueAndSelectedNotLearned = 0;
            falseAndNotSelected = 0;
            falseAndNotSelectedNotLearned = 0;
            trueButNotSelected = 0;
            trueButNotSelectedNotLearned = 0;
            falseButSelected = 0;
            falseButSelectedNotLearned = 0;

            filesTrueResults = new LearningAlgorithmML.Algorithm[goodImages.Length];
            filesFalseResults = new LearningAlgorithmML.Algorithm[badImages.Length];

            for (int i = 0; i < learnedTrue.Length; i++)
                learnedTrue[i] = false;
            for (int i = 0; i < learnedFalse.Length; i++)
                learnedFalse[i] = false;
        }