Example #1
0
 public Signal()
 {
     pca      = new PCA();
     knn      = new KNN();
     svm      = new SVM();
     svmscale = new SVMScale();
 }
Example #2
0
        public double buildSVMTestCorpus(string filename)
        {
            double total = 0, tp = 0;
            string trainDataPath = filename + "SimpleTrainSVM.txt";

            if (File.Exists(trainDataPath))
            {
                _test = ProblemHelper.ReadProblem(trainDataPath);
                _test = ProblemHelper.ScaleProblem(_test);
                svm_node[][] sn = _test.x;
                total = sn.Length;
                double[] lbls = _test.y;
                for (int i = 0; i < sn.Length; i++)
                {
                    if (_test.y[i] == svm.Predict(sn[i]))
                    {
                        tp++;
                    }
                }
                fileExistance = true;
                //ProblemHelper.WriteProblem(filename+"TestSVM.txt", _test);
            }
            else
            {
                SVMScale readyData = new SVMScale();
                readyData.buildSVMCorpus(filename);
                readyData.scaleSVMData(filename);
                buildSVMTestCorpus(filename);
            }
            return((tp / total) * 100);
        }
Example #3
0
        public SVM()
        {
            fileExistance        = false;
            predictionDictionary = new Dictionary <int, string> {
                { 1, "Neutral" }, { 2, "Up" }, { 3, "Down" }, { 4, "Left" }, { 5, "Right" }
            };
            scale   = new SVMScale();
            svmnode = new svm_node[25];
            int i = 0;

            for (; i < 25; i++)
            {
                svmnode[i]       = new svm_node();
                svmnode[i].index = i + 1;
            }
        }