Matthew Johnson

SVM.NET

Latest Stable Version - 1.4

This is an clean .NET conversion of libsvm 2.84, specifically from the Java version. Full functionality and efficiency is maintained, but the object structure has been modified to be more appropriate for the .NET platform (including C# and VB.NET). More information on the libsvm library can be found here. Using the library is quite straightforward. For example, if you have downloaded the sample data, then (using C#) you would train and test an SVM in the following manner:

//First, read in the training data.
 
Problem train = Problem.Read("a1a.train");
 
 
//Now, determine the range of the data so we can
//scale it to be uniform across all dimensions.
 
RangeTransform range = Scaling.DetermineRange(train);
 
 
//We now scale all data using that range.
 
train = Scaling.Scale(train, range);
Problem test = Problem.Read("a1a.test");
test = Scaling.Scale(test, range);
 
 
//For this example (and indeed, many scenarios), the default
//parameters will suffice.
Parameter parameters = new Parameter();
double C;
double Gamma;
 
 
//This will do a grid optimization to find the best parameters
//and store them in C and Gamma, outputting the entire
//search to params.txt.
 
ParameterSelection.Grid(train, parameters, "params.txt", out C, out Gamma);
parameters.C = C;
parameters.Gamma = Gamma;
 
 
//Train the model using the optimal parameters.
 
Model model = Training.Train(train, parameters);
 
 
//Perform classification on the test data, putting the
//results in results.txt.
 
Prediction.Predict(test, "results.txt", model, false);

Each class which needs to be saved has a Write() and Read() method that can be used for that purpose. Problem files are of the form:

[label] [index]:[value] [index]:[value] ...
...

Please refer to the libsvm site for more tutorials or information on support vector machines.

Revision Information

Version 1.4 (9/3/2008)

  • Added PerformanceEvaluator and RankPair classes which enable easy evaluation using Precision/Recall and Receiver Operating Characteristic Curves
  • Added PrecomputedKernel class, which makes it easier to train SVMs using custom kernels.
  • Small changes to improve performance. See documentation for details.

Version 1.3 (9/17/2007)

  • Updated to libsvm 2.84

Version 1.2 (3/27/2007)

  • Added the ability to predict class membership and probabilities for a single vector to the Prediction class.
  • Added the GaussianTransform class.
  • Fixed minor bugs and completed documentation.

Version 1.1 (2/19/2007)

  • Fixed a bug when writing to file, where the existing file wouldn't be completely overwritten.
  • Updated documentation.

Version 1.0 (2/16/2007)

  • First public release.
Snapshot