Click or drag to resize

SVM Density Estimation

Density estimation model

One-class SVM was proposed (B. Schölkopf, J. C. Platt, J. Shawe-Taylor, A. J. Smola, and R. C. Williamson. Estimating the support of a high-dimensional distribution. Neural Computation, 13(7):1443–1471, 2001. ) for estimating the support of a high-dimensional distribution. Given training vectors ML SVMClassification 1 without any class information, the primal problem of one-class SVM is

ML SVMDensity 2

subject to ML SVMDensity 3,

ML SVMMarginML SVMMarginML SVMDensity 4, ML SVMDensity 4 Ro.

Example

As you can see in the next four figures, the probability density function estimation performs as intuitively expected (compare to SVM probability estimation).

ML SVMDensity 5

ML SVMDensity 6

ML SVMDensity 7

ML SVMDensity 8

Implementation

SVMDensityEstimation class contains the following methods:

Method

Description

Performance

train

Train OneClass probability density estimation model

methodTrainOneClass(Matrix, Boolean, SVMKernelBase, Double, Double, Double, Int32, TimeSpan, Boolean)

classify

Estimate probability in observation point.

methodClassify(Vector)

Code Sample

The example of SVM Density Estimation usage:

C#
 1public static void ProbabilityOneClassTest()
 2{
 3    Console.WriteLine("********************************************************************");
 4    Console.WriteLine("ProbabilityOneClassTest");
 5    Console.WriteLine("********************************************************************");
 6
 7    Matrix xz = new Matrix(200, 2);
 8    for (int i = 0; i < 100; ++i)
 9    {
10        Double rho = i / 100.0;
11        Double theta = 100 * rho;
12        xz[i, 0] = rho * Math.Cos(theta) * 2 + 1;
13        xz[i, 1] = rho * Math.Sin(theta) + 2;
14        xz[i + 100, 0] = rho * Math.Cos(theta) - 1;
15        xz[i + 100, 1] = rho * Math.Sin(theta) * 2;
16    }
17
18    SVMDensityEstimation model = new SVMDensityEstimation();
19    model.TrainOneClass(xz, false);
20    model.Save("svm_s2_cpp");
21
22    Double pred_val;
23    for (int ri = 0; ri < xz.Rows; ++ri)
24        pred_val = model.Classify(xz.GetRow(ri));
25    Console.WriteLine($"Model {model.Type} with kernel {model.Kernel}");
26}

See Also