Exemplo n.º 1
0
 /*
  * this test is for finding the best optimization for SVM algorithm
  * trying sigma and gamma for the rbf kernel for best accuracy.
  */
 private void Internal_SVM(ImageVector[] goodImages, ImageVector[] badImages)
 {
     for (double i = 0; i <= 5; i += 1)
     {
         for (double j = 0; j <= 0; j += 1)
         {
             double sigma = Math.Pow(2, i);
             double gamma = Math.Pow(2, j);
             //learningAlgo = new SVM(userPath, i, 1, SVM.Kernel.SVM_POLY, goodImages, badImages);
             learningAlgo = new SVM_Matlab(userPath, sigma, 1, SVM_Matlab.Kernel.SVM_RBF, goodImages, badImages);
             crossValidation(goodImages, badImages);
         }
     }
 }
Exemplo n.º 2
0
        public void Tests(out ImageVector[] goodImages, out ImageVector[] badImages)
        {
            goodImages = null;
            badImages = null;

            // 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;

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

            //contains the parameters for each picture and the picture path

            extractAlbum(out goodImages, out badImages, filesTrue, filesFalse, userPath, false);

            // remove comment if you want to optimize one of the algorithms

            // optimize svm
            // Internal_SVM(goodImages, badImages);
            // optimize knn
            // Internal_KNN(goodImages, badImages);
            // optimize knn and svm`
            // Internal_KNN_SVM(goodImages, badImages, true); //regular intersection
            //testIntersection(goodImages, badImages); //smart intersection
            int k = 2;
            for (double i = 0; i <= 5; i += 1)
            {
                for (double j = 0; j <= 0; j += 1)
                {
                    double sigma = Math.Pow(2, i);
                    double gamma = Math.Pow(2, j);
                    learningAlgo = new KNN_SVM(userPath, sigma, gamma, KNN_SVM.Kernel.SVM_RBF, k, goodImages, badImages);
                }
            }
            // test using cross validation
            //learningAlgo = new SVM_Matlab(userPath, -5, -5, SVM_Matlab.Kernel.SVM_RBF);
            //svm = new SVM(SVM.Kernel.SVM_RBF, 1, 1);
            //crossValidation(goodImages, badImages);
            // test on different albums
            //differentAlbums(goodImages, badImages);

            //  copyGoodImages(filesTrue, filesFalse);

            learningAlgo.Quit();
        }
Exemplo n.º 3
0
        //, Boolean isTest)
        /*
         * this test is for finding the best optimization for SVM algorithm
         * trying sigma and gamma for the rbf kernel for best accuracy.
         */
        public void Internal_KNN_SVM(ImageVector[] goodImages, ImageVector[] badImages)
        {
            int k = 2;
            for (double i = 0; i <= 5; i += 1)
            {
                for (double j = 0; j <= 0; j += 1)
                {
                    double sigma = Math.Pow(2, i);
                    double gamma = Math.Pow(2, j);
                    learningAlgo = new KNN_SVM(userPath, sigma, gamma, KNN_SVM.Kernel.SVM_RBF, k, goodImages, badImages);
                    if (!isTest)
                    {
                            crossValidation(goodImages, badImages);

                    }
                    else
                        crossValidation_second(goodImages, badImages);
                }
            }
        }
Exemplo n.º 4
0
 public void testIntersection(ImageVector[] goodImages, ImageVector[] badImages)
 {
     for (double conf = 0.5; conf <= 0.5; conf += 0.1)
     {
         SVM_Matlab.CONFIDENCE_BAR = conf;
         learningAlgo = new smartIntersection(userPath, goodImages, badImages);
         crossValidation(goodImages, badImages);
     }
 }
Exemplo n.º 5
0
 /*
  * this test is for finding the best optimization for KNN algorithm
  * finding the best k for this classification
  */
 public void Internal_KNN(ImageVector[] goodImages, ImageVector[] badImages)
 {
     for (int k = 2; k <= 2; k++)
     {
         learningAlgo = new KNN_Matlab(userPath, k, goodImages, badImages);
         crossValidation(goodImages, badImages);
     }
 }