00001 #include "AbstractSVM.h" 00002 00003 namespace damina 00004 { 00005 00009 AbstractSVM::AbstractSVM() { 00010 testSet = NULL; 00011 } 00012 00016 AbstractSVM::~AbstractSVM() { 00017 delete trainingSet; 00018 if (testSet != NULL) delete testSet; 00019 } 00020 00021 00031 void AbstractSVM::setKernel(int k) { 00032 this->params->kernel_type = k; 00033 } 00034 00046 void AbstractSVM::setKernel(int k, double width) { 00047 this->params->kernel_type = k; 00048 this->params->gamma = width; 00049 } 00050 00063 void AbstractSVM::setKernel(int k, int degree) { 00064 this->params->kernel_type = k; 00065 this->params->degree = degree; 00066 } 00067 00068 00083 void AbstractSVM::setKernel(int k, int degree, double width) { 00084 this->params->kernel_type = k; 00085 this->params->degree = degree; 00086 this->params->gamma = width; 00087 } 00088 00095 void AbstractSVM::setKernelWidth(double w) { 00096 this->params->gamma = w; 00097 } 00098 00106 void AbstractSVM::setKernelDegree(int deg) { 00107 this->params->degree = deg; 00108 } 00109 00110 00123 void AbstractSVM::setTolerance(double t) { 00124 this->params->eps = t; 00125 } 00126 00134 void AbstractSVM::setCacheSize(int sizeMB) { 00135 this->params->cache_size = sizeMB; 00136 } 00137 00143 void AbstractSVM::setTestSet(DataSet *test) { 00144 this->testSet = test; 00145 } 00146 00152 void AbstractSVM::setTrainingSet(DataSet *train) { 00153 this->trainingSet = train; 00154 } 00155 00161 DataSet *AbstractSVM::getTestSet() { 00162 return this->testSet; 00163 } 00164 00165 00171 DataSet *AbstractSVM::getTrainingSet() { 00172 return this->trainingSet; 00173 } 00174 00175 00181 int AbstractSVM::getKernel() { 00182 return this->params->kernel_type; 00183 } 00184 00185 00191 int AbstractSVM::getKernelDegree() { 00192 return this->params->degree; 00193 } 00194 00200 double AbstractSVM::getKernelWidth() { 00201 return this->params->gamma; 00202 } 00203 00204 00210 double AbstractSVM::getTolerance() { 00211 return this->params->eps; 00212 } 00213 00219 double AbstractSVM::getCacheSize() { 00220 return this->params->cache_size; 00221 } 00222 00223 00235 void AbstractSVM::enableShrinkingHeuristics() { 00236 this->params->shrinking = 1; 00237 } 00238 00239 00251 void AbstractSVM::disableShrinkingHeuristics() { 00252 this->params->shrinking = 0; 00253 } 00254 00267 bool AbstractSVM::isShrinkingHeuristicsEnabled() { 00268 if (this->params->shrinking) 00269 return true; 00270 00271 return false; 00272 } 00273 00279 struct svm_parameter *AbstractSVM::getParameters() { 00280 return params; 00281 } 00282 }
1.5.2