#include <OneClassSVM.h>
Inheritance diagram for damina::OneClassSVM:


Public Member Functions | |
| virtual void | classify (DataSet *) |
| The classification process. | |
| virtual void | classify () |
| The classification process. | |
| virtual void | disableShrinkingHeuristics () |
| Disable the Shrinking Heuristics. | |
| virtual void | enableShrinkingHeuristics () |
| Enable the Shrinking Heuristics. | |
| virtual double | getCacheSize () |
| Returns the current kernel cache size. | |
| virtual int | getKernel () |
| Returns the current kernel type. | |
| virtual int | getKernelDegree () |
| Returns the degree of the current kernel. | |
| virtual double | getKernelWidth () |
| Returns the gamma of the current kernel. | |
| virtual struct svm_model * | getModel () |
| Returns the trained model. | |
| virtual double | getNU () |
| Returns the current values for 'nu' parameter. | |
| virtual struct svm_parameter * | getParameters () |
| Returns the SVM paramters. | |
| virtual struct svm_problem * | getProblem () |
| Returns the problem in libsvm format. | |
| virtual DataSet * | getTestSet () |
| Returns the current test set. | |
| virtual double | getTolerance () |
| Returns the tolerance of the stopping criteria. | |
| virtual DataSet * | getTrainingSet () |
| Returns the current training set. | |
| virtual bool | isShrinkingHeuristicsEnabled () |
| Returns true if the Shrinking is enabled. | |
| virtual void | learn (struct svm_problem *) |
| Perform the learning process. | |
| virtual void | learn (DataSet *) |
| Perform the learning process. | |
| virtual void | learn () |
| Perform the learning process. | |
| OneClassSVM (struct svm_problem *) | |
| Constructor. | |
| OneClassSVM (DataSet *) | |
| Constructor. | |
| OneClassSVM () | |
| Constructor. | |
| virtual void | setCacheSize (int) |
| Set the kernel cache size. | |
| virtual void | setKernel (int, int, double) |
| Set the kernel type, the kernel degree and the kernel width for the SVM. | |
| virtual void | setKernel (int, double) |
| Set both the kernel type and the kernel width (gamma) for the SVM. | |
| virtual void | setKernel (int, int) |
| Set both the kernel type and the kernel degree for the SVM. | |
| virtual void | setKernel (int) |
| Set the kernel type for the SVM. | |
| virtual void | setKernelDegree (int) |
| Set the kernel degree for the SVM. | |
| virtual void | setKernelWidth (double) |
| Set the kernel width (gamma) for the SVM. | |
| virtual void | setNU (double) |
| Set the nu parameter for the One Class SVM. | |
| virtual void | setProblem (struct svm_problem *) |
| Set the new problem in libsvm format for the learning process. | |
| virtual void | setTestSet (DataSet *) |
| Set the test set. | |
| virtual void | setTolerance (double) |
| Set the tolerance of termination criterion. | |
| virtual void | setTrainingSet (DataSet *) |
| Set the new training set. | |
| virtual | ~OneClassSVM () |
| Destructor. | |
Protected Attributes | |
| svm_parameter * | params |
| The configuration parameters for set up an SVM using LibSVM. | |
| DataSet * | testSet |
| The test set. | |
| DataSet * | trainingSet |
| The training set. | |
Private Member Functions | |
| virtual void | trainingSetToProblem () |
| Convert a training set format to svm_problem libsvm format. | |
Private Attributes | |
| svm_model * | model |
| The trained model. | |
| svm_problem * | problem |
| The problem (Training Set) in the LibSVM format. | |
The problem in one-class classification is to make a description of a target set of objects and to detect which (new) objects resemble this training set. The difference with conventional classification is that in one-class classification only examples of one class are available. The objects from this class will be called the target objects. All other objects are per definition the outlier objects.
One-class SVM was proposed by Schoelkopf et al. (2001) for estimating the support of a high-dimensional distribution and it is based on the nu-SVM variant by Schoelkopf et al. (2000)
References:
B. Schoelkopf, 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.
B. Schoelkopf, A. Smola, R. C. Williamson, and P. L. Bartlett. New support vector algorithms. Neural Computation, 12:1207–1245, 2000.
Definition at line 34 of file OneClassSVM.h.
| damina::OneClassSVM::OneClassSVM | ( | ) |
Constructor.
Definition at line 11 of file OneClassSVM.cpp.
References damina::AbstractSVM::params.
00011 { 00012 this->params = (struct svm_parameter *)malloc(sizeof(struct svm_parameter)); 00013 this->params->svm_type = ONE_CLASS; 00014 }
| damina::OneClassSVM::OneClassSVM | ( | DataSet * | train | ) |
Constructor.
| The | training set |
Definition at line 21 of file OneClassSVM.cpp.
References damina::AbstractSVM::params, and trainingSetToProblem().
00021 { 00022 this->params = (struct svm_parameter *)malloc(sizeof(struct svm_parameter)); 00023 this->params->svm_type = ONE_CLASS; 00024 this->trainingSetToProblem(); 00025 }
Here is the call graph for this function:

| damina::OneClassSVM::OneClassSVM | ( | struct svm_problem * | prob | ) |
Constructor.
| The | problem in libsvm format |
Definition at line 32 of file OneClassSVM.cpp.
References damina::AbstractSVM::params, and problem.
00032 { 00033 this->params = (struct svm_parameter *)malloc(sizeof(struct svm_parameter)); 00034 this->params->svm_type = ONE_CLASS; 00035 this->problem = prob; 00036 }
| damina::OneClassSVM::~OneClassSVM | ( | ) | [virtual] |
| void damina::OneClassSVM::classify | ( | DataSet * | test | ) | [virtual] |
The classification process.
| test | The test set to set before run the classification process |
Implements damina::ClassificationEngine.
Definition at line 149 of file OneClassSVM.cpp.
| void damina::OneClassSVM::classify | ( | ) | [virtual] |
The classification process.
Implements damina::ClassificationEngine.
Definition at line 139 of file OneClassSVM.cpp.
| void damina::AbstractSVM::disableShrinkingHeuristics | ( | ) | [virtual, inherited] |
Disable the Shrinking Heuristics.
Since for many problems the number of free support vectors is small, the shrinking technique reduces the size of the working problem without considering some bounded variables.
References: T. Joachims, "Making large-scale support vector machine learning practical," , Schölkopf, B., Burges, C., and Smola, A., Eds., MIT Press, Cambridge, MA, 1998.
Definition at line 251 of file AbstractSVM.cpp.
References damina::AbstractSVM::params.
00251 { 00252 this->params->shrinking = 0; 00253 }
| void damina::AbstractSVM::enableShrinkingHeuristics | ( | ) | [virtual, inherited] |
Enable the Shrinking Heuristics.
Since for many problems the number of free support vectors is small, the shrinking technique reduces the size of the working problem without considering some bounded variables.
References: T. Joachims, "Making large-scale support vector machine learning practical," , Schölkopf, B., Burges, C., and Smola, A., Eds., MIT Press, Cambridge, MA, 1998.
Definition at line 235 of file AbstractSVM.cpp.
References damina::AbstractSVM::params.
00235 { 00236 this->params->shrinking = 1; 00237 }
| double damina::AbstractSVM::getCacheSize | ( | ) | [virtual, inherited] |
Returns the current kernel cache size.
Definition at line 219 of file AbstractSVM.cpp.
References damina::AbstractSVM::params.
00219 { 00220 return this->params->cache_size; 00221 }
| int damina::AbstractSVM::getKernel | ( | ) | [virtual, inherited] |
Returns the current kernel type.
Definition at line 181 of file AbstractSVM.cpp.
References damina::AbstractSVM::params.
Referenced by damina::SVClustering::getKernelType().
00181 { 00182 return this->params->kernel_type; 00183 }
Here is the caller graph for this function:

| int damina::AbstractSVM::getKernelDegree | ( | ) | [virtual, inherited] |
Returns the degree of the current kernel.
Definition at line 191 of file AbstractSVM.cpp.
References damina::AbstractSVM::params.
00191 { 00192 return this->params->degree; 00193 }
| double damina::AbstractSVM::getKernelWidth | ( | ) | [virtual, inherited] |
Returns the gamma of the current kernel.
Definition at line 200 of file AbstractSVM.cpp.
References damina::AbstractSVM::params.
Referenced by damina::SVClustering::getKernelWidth().
00200 { 00201 return this->params->gamma; 00202 }
Here is the caller graph for this function:

| struct svm_model * damina::OneClassSVM::getModel | ( | ) | [read, virtual] |
Returns the trained model.
The trained model, with objective function, lagrangians, etc.
Definition at line 160 of file OneClassSVM.cpp.
References model.
Referenced by damina::SVClustering::beta(), damina::SVClustering::calculateDistanceFromCenter(), damina::SVClustering::calculateQuadraticPartOfDistanceFromCenter(), damina::CCLSVClustering::experimentalSeparateClusters(), damina::SVClustering::getModel(), damina::SVClustering::rho(), and damina::CCLSVClustering::separateClusters().
00160 { 00161 return this->model; 00162 }
Here is the caller graph for this function:

| double damina::OneClassSVM::getNU | ( | ) | [virtual] |
Returns the current values for 'nu' parameter.
The parameter 'nu' in (0,1] in an upper bound on the fraction of training errors and a lower bound of the fraction of support vectors.
Definition at line 70 of file OneClassSVM.cpp.
References damina::AbstractSVM::params.
00070 { 00071 return this->params->nu; 00072 }
| struct svm_parameter * damina::AbstractSVM::getParameters | ( | ) | [read, virtual, inherited] |
Returns the SVM paramters.
Definition at line 279 of file AbstractSVM.cpp.
References damina::AbstractSVM::params.
Referenced by damina::SVClustering::getParameters().
00279 { 00280 return params; 00281 }
Here is the caller graph for this function:

| struct svm_problem * damina::OneClassSVM::getProblem | ( | ) | [read, virtual] |
Returns the problem in libsvm format.
Definition at line 119 of file OneClassSVM.cpp.
References problem.
Referenced by damina::CCLSVClustering::experimentalSeparateClusters(), damina::SVClustering::getOriginalClasses(), damina::SVClustering::getProblem(), damina::SVClustering::initialKernelWidth(), damina::SVClustering::separateClusters(), and damina::CCLSVClustering::separateClusters().
00119 { 00120 return this->problem; 00121 }
Here is the caller graph for this function:

| DataSet * damina::AbstractSVM::getTestSet | ( | ) | [virtual, inherited] |
Returns the current test set.
Implements damina::LearningEngine.
Definition at line 161 of file AbstractSVM.cpp.
References damina::AbstractSVM::testSet.
00161 { 00162 return this->testSet; 00163 }
| double damina::AbstractSVM::getTolerance | ( | ) | [virtual, inherited] |
Returns the tolerance of the stopping criteria.
Definition at line 210 of file AbstractSVM.cpp.
References damina::AbstractSVM::params.
00210 { 00211 return this->params->eps; 00212 }
| DataSet * damina::AbstractSVM::getTrainingSet | ( | ) | [virtual, inherited] |
Returns the current training set.
Implements damina::LearningEngine.
Definition at line 171 of file AbstractSVM.cpp.
References damina::AbstractSVM::trainingSet.
Referenced by damina::SVClustering::getTrainingSet(), and trainingSetToProblem().
00171 { 00172 return this->trainingSet; 00173 }
Here is the caller graph for this function:

| bool damina::AbstractSVM::isShrinkingHeuristicsEnabled | ( | ) | [virtual, inherited] |
Returns true if the Shrinking is enabled.
False otherwise.
Since for many problems the number of free support vectors is small, the shrinking technique reduces the size of the working problem without considering some bounded variables.
References: T. Joachims, "Making large-scale support vector machine learning practical," , Schölkopf, B., Burges, C., and Smola, A., Eds., MIT Press, Cambridge, MA, 1998.
Definition at line 267 of file AbstractSVM.cpp.
| void damina::OneClassSVM::learn | ( | struct svm_problem * | p | ) | [virtual] |
Perform the learning process.
| p | The new problem in libsvm format to use in learning process |
Definition at line 99 of file OneClassSVM.cpp.
References learn(), and setProblem().
00099 { 00100 this->setProblem(p); 00101 this->learn(); 00102 }
Here is the call graph for this function:

| void damina::OneClassSVM::learn | ( | DataSet * | ts | ) | [virtual] |
Perform the learning process.
| ts | The new training set to use in learning process |
Implements damina::LearningEngine.
Definition at line 88 of file OneClassSVM.cpp.
References learn(), setTrainingSet(), and trainingSetToProblem().
00088 { 00089 this->setTrainingSet(ts); 00090 this->trainingSetToProblem(); 00091 this->learn(); 00092 }
Here is the call graph for this function:

| void damina::OneClassSVM::learn | ( | ) | [virtual] |
Perform the learning process.
Implements damina::LearningEngine.
Definition at line 79 of file OneClassSVM.cpp.
References model.
Referenced by damina::SVClustering::learn(), and learn().
00079 { 00080 this->model = svm_train(this->problem, this->params); 00081 }
Here is the caller graph for this function:

| void damina::AbstractSVM::setCacheSize | ( | int | sizeMB | ) | [virtual, inherited] |
Set the kernel cache size.
The kernel cache is used to store the kernel values already computed
| sizeMB | The cache size im Megabytes |
Definition at line 134 of file AbstractSVM.cpp.
References damina::AbstractSVM::params.
Referenced by damina::SVClustering::SVClustering().
00134 { 00135 this->params->cache_size = sizeMB; 00136 }
Here is the caller graph for this function:

| void damina::AbstractSVM::setKernel | ( | int | k, | |
| int | degree, | |||
| double | width | |||
| ) | [virtual, inherited] |
Set the kernel type, the kernel degree and the kernel width for the SVM.
The values representing the Kernel Types are available in the KernelType class as public static attributes. The degree is only for the Polynomial Kernel. If you set a different type of Kernel with this method, the degree will be simply ignored. The gamma (width) parameter is ignored in case of Linear Kernel.
| k | The integer value representing the Kernel Type | |
| degree | An integer value representing the degree in the Polynomial Kernel | |
| width | The kernel gamma, a real value in [0,1] |
Definition at line 83 of file AbstractSVM.cpp.
References damina::AbstractSVM::params.
00083 { 00084 this->params->kernel_type = k; 00085 this->params->degree = degree; 00086 this->params->gamma = width; 00087 }
| void damina::AbstractSVM::setKernel | ( | int | k, | |
| double | width | |||
| ) | [virtual, inherited] |
Set both the kernel type and the kernel width (gamma) for the SVM.
The values representing the Kernel Types are available in the KernelType class as public static attributes. The gamma (width) parameter is ignored in case of Linear Kernel.
| k | The integer value representing the Kernel Type | |
| width | The kernel gamma, a real value in [0,1] |
Definition at line 46 of file AbstractSVM.cpp.
References damina::AbstractSVM::params.
| void damina::AbstractSVM::setKernel | ( | int | k, | |
| int | degree | |||
| ) | [virtual, inherited] |
Set both the kernel type and the kernel degree for the SVM.
The values representing the Kernel Types are available in the KernelType class as public static attributes. The degree is only for the Polynomial Kernel. If you set a different type of Kernel with this method, the degree will be simply ignored.
| k | The integer value representing the Kernel Type | |
| degree | An integer value representing the degree in the Polynomial Kernel |
Definition at line 63 of file AbstractSVM.cpp.
References damina::AbstractSVM::params.
| void damina::AbstractSVM::setKernel | ( | int | k | ) | [virtual, inherited] |
Set the kernel type for the SVM.
The values representing the Kernel Types are available in the KernelType class as public static attributes.
| k | The integer value representing the Kernel Type |
Definition at line 31 of file AbstractSVM.cpp.
References damina::AbstractSVM::params.
Referenced by damina::SVClustering::setKernelType(), and damina::SVClustering::SVClustering().
00031 { 00032 this->params->kernel_type = k; 00033 }
Here is the caller graph for this function:

| void damina::AbstractSVM::setKernelDegree | ( | int | deg | ) | [virtual, inherited] |
Set the kernel degree for the SVM.
The degree is only for the Polynomial Kernel. If you set a different type of Kernel, the degree will be simply ignored.
| deg | An integer value representing the degree in the Polynomial Kernel |
Definition at line 106 of file AbstractSVM.cpp.
References damina::AbstractSVM::params.
00106 { 00107 this->params->degree = deg; 00108 }
| void damina::AbstractSVM::setKernelWidth | ( | double | w | ) | [virtual, inherited] |
Set the kernel width (gamma) for the SVM.
The gamma (width) parameter is ignored in case of Linear Kernel.
| w | The kernel gamma, a real value in [0,1] |
Definition at line 95 of file AbstractSVM.cpp.
References damina::AbstractSVM::params.
Referenced by damina::SVClustering::initialKernelWidth(), damina::SVClustering::setKernelWidth(), and damina::SVClustering::SVClustering().
00095 { 00096 this->params->gamma = w; 00097 }
Here is the caller graph for this function:

| void damina::OneClassSVM::setNU | ( | double | nu | ) | [virtual] |
Set the nu parameter for the One Class SVM.
The parameter 'nu' in (0,1] in an upper bound on the fraction of training errors and a lower bound of the fraction of support vectors.
| nu | The nu parameter for the OneClass SVM |
Definition at line 57 of file OneClassSVM.cpp.
References damina::AbstractSVM::params.
Referenced by damina::SVClustering::setSoftConstraint(), and damina::SVClustering::SVClustering().
00057 { 00058 this->params->nu = nu; 00059 }
Here is the caller graph for this function:

| void damina::OneClassSVM::setProblem | ( | struct svm_problem * | p | ) | [virtual] |
Set the new problem in libsvm format for the learning process.
| p | The new problem in libsvm format to use in learning process |
Definition at line 109 of file OneClassSVM.cpp.
References problem.
Referenced by learn(), damina::SVClustering::setProblem(), and damina::SVClustering::SVClustering().
00109 { 00110 this->problem = p; 00111 }
Here is the caller graph for this function:

| void damina::AbstractSVM::setTestSet | ( | DataSet * | test | ) | [virtual, inherited] |
Set the test set.
| test | The test set |
Implements damina::LearningEngine.
Definition at line 143 of file AbstractSVM.cpp.
References damina::AbstractSVM::testSet.
00143 { 00144 this->testSet = test; 00145 }
| void damina::AbstractSVM::setTolerance | ( | double | t | ) | [virtual, inherited] |
Set the tolerance of termination criterion.
Pratically, the training of an SVM is always sub-optimal and a stop criterion is used to choose when the training algorithm will stop.
This method set the tolerance of the criterion used in the LibSVM.
| t | A real-valued parameter representing the tolerance of the termination criterion. Usually it assumes values between 0.001 and 0.00001 |
Definition at line 123 of file AbstractSVM.cpp.
References damina::AbstractSVM::params.
Referenced by damina::SVClustering::SVClustering().
00123 { 00124 this->params->eps = t; 00125 }
Here is the caller graph for this function:

| void damina::OneClassSVM::setTrainingSet | ( | DataSet * | ts | ) | [virtual] |
Set the new training set.
| ts | The training set to set |
Reimplemented from damina::AbstractSVM.
Definition at line 129 of file OneClassSVM.cpp.
References damina::AbstractSVM::setTrainingSet(), and trainingSetToProblem().
Referenced by learn(), damina::SVClustering::setTrainingSet(), and damina::SVClustering::SVClustering().
00129 { 00130 AbstractSVM::setTrainingSet(ts); 00131 this->trainingSetToProblem(); 00132 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void damina::OneClassSVM::trainingSetToProblem | ( | ) | [private, virtual] |
Convert a training set format to svm_problem libsvm format.
Definition at line 172 of file OneClassSVM.cpp.
References damina::Point::get(), damina::DataSet::get(), damina::Feature::getIndex(), damina::Point::getLabel(), damina::Point::getSize(), damina::DataSet::getSize(), damina::AbstractSVM::getTrainingSet(), damina::Feature::getValue(), and problem.
Referenced by learn(), OneClassSVM(), and setTrainingSet().
00172 { 00173 DataSet *ts = this->getTrainingSet(); 00174 Point *temp; 00175 00176 unsigned long int i, j; 00177 00178 this->problem->l = ts->getSize(); 00179 this->problem->y = (double *) malloc(this->problem->l * sizeof(double)); 00180 this->problem->x = (struct svm_node **) malloc(this->problem->l * sizeof(struct svm_node*)); 00181 00182 // iteration on Points 00183 for (i = 0; i < ts->getSize(); i++) { 00184 temp = ts->get(i); 00185 00186 this->problem->x[i] = (struct svm_node*) malloc((temp->getSize() + 1) * sizeof(struct svm_node)); 00187 this->problem->y[i] = temp->getLabel(); 00188 00189 //iteration on Features 00190 for (j = 0; j < temp->getSize(); j++) { 00191 this->problem->x[i][j].index = temp->get(j)->getIndex(); 00192 this->problem->x[i][j].value = temp->get(j)->getValue(); 00193 } 00194 00195 this->problem->x[i][j].index = -1; 00196 this->problem->x[i][j].value = 0; 00197 } 00198 }
Here is the call graph for this function:

Here is the caller graph for this function:

struct svm_model* damina::OneClassSVM::model [read, private] |
The trained model.
It contains also the computed lagrangian multipliers.
Definition at line 47 of file OneClassSVM.h.
Referenced by getModel(), and learn().
struct svm_parameter* damina::AbstractSVM::params [read, protected, inherited] |
The configuration parameters for set up an SVM using LibSVM.
Definition at line 36 of file AbstractSVM.h.
Referenced by damina::AbstractSV