SVM Probability Classification |
This is simple example of classification with probability estimation. As you can see, the main difference from probability density function (pdf) estimation algorithms (like, for example GMM), is that the probability can change too quickly if classes can be clearly separated even in the low pdf area. So SVC probability describes mostly not pdf, but the hyperplane.
SVMClassificationProbability class inherits from SVMClassification and also features the following methods:
Method | Description | Performance |
---|---|---|
set random seed | Set random seed for LIBSVM classification train with probability estimation. | |
classify | Classifies observation vector into one of the classes and estimate probabilities. |
The example of SVM Probability CVS Classification usage:
1public static void ProbabilitySVCTest() 2{ 3 Console.WriteLine("********************************************************************"); 4 Console.WriteLine("ProbabilitySVCTest"); 5 Console.WriteLine("********************************************************************"); 6 7 Matrix xz = new Matrix(200, 2); 8 IntegerArray cl = new IntegerArray(xz.Rows); 9 10 for (int i = 0; i < 100; ++i) 11 { 12 Double rho = i / 100.0; 13 Double theta = 100 * rho; 14 xz[i, 0] = rho * Math.Cos(theta) * 2 + 1; 15 xz[i, 1] = rho * Math.Sin(theta) + 2; 16 xz[i + 100, 0] = rho * Math.Cos(theta) - 1; 17 xz[i + 100, 1] = rho * Math.Sin(theta) * 2; 18 cl[i] = i < xz.Rows / 2 ? 1 : 2; 19 } 20 21 SVMClassificationProbability model = new SVMClassificationProbability(); 22 SVMClassificationProbability.SetRandomSeed(1); 23 model.TrainCSVC(xz, cl, false); 24 model.Save("svm_b1rnd1_cpp"); 25 26 Vector prob = new Vector(model.Classes.Length); 27 28 for (int ri = 0; ri < xz.Rows; ++ri) 29 model.Classify(xz.GetRow(ri), ref prob); 30 Console.WriteLine($"Model {model.Type} with kernel {model.Kernel}"); 31}