If anyone is familiar with libSVM (https://www.csie.ntu.edu.tw/~cjlin/libsvm/), I am working with libSVMsharp, which is the same thing, in a C# wrapper, I believe.
On their github, they give the following example of how to write a simple classification, using the SVM:
SVMProblem problem = SVMProblemHelper.Load(@"dataset_path.txt");
SVMProblem testProblem = SVMProblemHelper.Load(@"test_dataset_path.txt");
SVMParameter parameter = new SVMParameter();
parameter.Type = SVMType.C_SVC;
parameter.Kernel = SVMKernelType.RBF;
parameter.C = 1;
parameter.Gamma = 1;
SVMModel model = SVM.Train(problem, parameter);
double target[] = new double[testProblem.Length];
for (int i = 0; i < testProblem.Length; i++)
target[i] = SVM.Predict(model, testProblem.X[i]);
double accuracy = SVMHelper.EvaluateClassificationProblem(testProblem, target);
That all makes perfect sense, loading in the training data with its path specified, and same with the test data...Well, that's where I run into problems.
I wanted to test this out in C# just to ensure my full understanding of how this works, before implementing it in a larger project that I've been working on. I have a small program called Program.cs (very original, I know), and in the SAME FOLDER, I have train.txt and test.txt. So we have a folder that contains Program.cs, train.txt, and test.txt, along with some other standard stuff that is created when you make a project in Visual Studio.
So that snippet of my code looks like this:
SVMProblem trainingSet = SVMProblemHelper.Load(@"train.txt");
SVMProblem testSet = SVMProblemHelper.Load(@"test.txt");
trainingSet = trainingSet.Normalize(SVMNormType.L2);
testSet = testSet.Normalize(SVMNormType.L2);
and so on. However, when I run this, it basically says that the variable "trainingSet" is null, because SVMProblemHelper never actually managed to load train.txt.
I feel like there is a glaringly obvious solution to this, but I'm completely lost. I'm not entirely sure what's going wrong, here. In the SVMProblemHelper.Load function, it basically says that it will set the variable (in this case, trainingSet) equal to null if it cannot find the file in question. But how is it not finding the file? It's in the same directory as the .cs file. I'm not sure what I'm missing but I can't figure it out.
Any help is gladly welcomed!