Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/20/10 16:47:12 (15 years ago)
Author:
mkommend
Message:

added calculation and view for support vectors (ticket #1009)

Location:
trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.LibSVM/1.6.3/LibSVM-1.6.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.LibSVM/1.6.3/LibSVM-1.6.3/Model.cs

    r2645 r3858  
    3333    private int _numberOfClasses;
    3434    private int _supportVectorCount;
     35    private int[] _supportVectorIndizes;
    3536    private Node[][] _supportVectors;
    3637    private double[][] _supportVectorCoefficients;
     
    7879      set {
    7980        _supportVectorCount = value;
     81      }
     82    }
     83
     84    /// <summary>
     85    /// Indizes of support vectors identified in the training.
     86    /// </summary>
     87    public int[] SupportVectorIndizes {
     88      get {
     89        return _supportVectorIndizes;
     90      }
     91      set {
     92        _supportVectorIndizes = value;
    8093      }
    8194    }
  • trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.LibSVM/1.6.3/LibSVM-1.6.3/Solver.cs

    r2645 r3858  
    16731673                    if (Math.Abs(f.alpha[i]) > 0) ++nSV;               
    16741674                model.SupportVectorCount = nSV;
     1675                model.SupportVectorIndizes = new int[nSV];
    16751676                model.SupportVectors = new Node[nSV][];
    16761677                model.SupportVectorCoefficients[0] = new double[nSV];
     1678               
    16771679                int j = 0;
    16781680                for (i = 0; i < prob.Count; i++)
     
    16801682                    {
    16811683                        model.SupportVectors[j] = prob.X[i];
     1684                        model.SupportVectorIndizes[j] = i;
    16821685                        model.SupportVectorCoefficients[0][j] = f.alpha[i];
     1686                       
    16831687                        ++j;
    16841688                    }
     
    18201824                model.SupportVectorCount = nnz;
    18211825                model.SupportVectors = new Node[nnz][];
     1826                model.SupportVectorIndizes = new int[nnz];
    18221827                p = 0;
    1823                 for (i = 0; i < l; i++)
    1824                     if (nonzero[i]) model.SupportVectors[p++] = x[i];
     1828                for (i = 0; i < l; i++) {
     1829                  if (nonzero[i]) {
     1830                    model.SupportVectors[p] = x[i];
     1831                    model.SupportVectorIndizes[p] = i;
     1832                    p++;
     1833                  }
     1834                }
    18251835
    18261836                int[] nz_start = new int[nr_class];
Note: See TracChangeset for help on using the changeset viewer.