An easy way to use Support Vector Machines in your .NET projects (c# code)
Perl C#
Latest commit e730383 Apr 25, 2016 @nicolaspanel Update

New owner required

Since I have not been developing in .NET for a while and I don't use Windows anymore, I cannot maintain this library any longer. Let me know if you want to take over. is an easy way to use Support Vector Machines in your .NET projects.

Current version : 2.1.8

##How to use it First of all, if you are not familiar with SVM, I highly recommend to read this guide.

You can use right now, using the following NuGet package : PM> Install-Package

Note : For now, C-SVC and epsilon-SVR are supported. nu-SVC and nu-SVR will be available in future versions.

Classification (using C_SVC)

The code below describe the main methods :

var prob = ProblemHelper.ReadAndScaleProblem(TRAINING_FILE);
var test = ProblemHelper.ReadAndScaleProblem(TEST_FILE);

var svm = new C_SVC(prob, KernelHelper.RadialBasisFunctionKernel(gamma), C);
var accuracy = svm.GetCrossValidationAccuracy(nr_fold);// with nr_fold > 1
for (int i = 0 ; i < test.l ; i++)
    var x = test.x[i];
    var y = test.y[i];
    var predictedY = svm.Predict(x); // returns the predicted value for 'x' attributes
    var probabilities = svm.PredictProbabilities(x);  // returns the probabilities for each class
    // Note : in about accuracy% of cases, 'predictedY' should be equal to 'y'

Of course you can choose other kernels if you want (see KernelHelper class for more informations).

Regression (using Epsilon_SVR)

Regression methods are a little different but the spirit remains the same :

var svm = new Epsilon_SVR(prob, KernelHelper.RadialBasisFunctionKernel(gamma), C, epsilon);
double mse = svm.GetMeanSquaredError(); 
var prediction = svm.Predict(x);

Advance options

Since version 2.1.0 (thanks to ccerhan), you can also save your models into xml files. This avoids having to train your model again and again when the dataset did'nt changed.

License is provided under MIT License.


Feel free to fork and improve/enhance in any way your want.

If you feel that the community will benefit from your changes, please send a pull request!


How it works uses the official libsvm Java library, version 3.17 translated to .NET using IKVM. It also provides helpers and classes to facilitate its use in real projects.

For more informations, see also : alpha