47 #define SVMTYPE_ID "SvmType"
48 #define KERNELTYPE_ID "KernelType"
49 #define DEGREE_ID "Degree"
50 #define GAMMA_ID "Gamma"
51 #define COEF0_ID "Coef0"
54 #define PROB_ID "ProbabilisticOutput"
55 #define PSEUDO_ID "NumberOfPseudoAbsences"
57 #define SVM_LOG_PREFIX "SvmAlgorithm: "
69 "Type of SVM: 0 = C-SVC, 1 = Nu-SVC, 2 = one-class SVM",
70 "Type of SVM: 0 = C-SVC, 1 = Nu-SVC, 2 = one-class SVM",
82 "Type of kernel function: 0 = linear: u'*v , 1 = polynomial: (gamma*u'*v + coef0)^degree , 2 = radial basis function: exp(-gamma*|u-v|^2)",
83 "Type of kernel function: 0 = linear: u'*v , 1 = polynomial: (gamma*u'*v + coef0)^degree , 2 = radial basis function: exp(-gamma*|u-v|^2)",
95 "Degree in kernel function (only for polynomial kernels).",
96 "Degree in kernel function (only for polynomial kernels).",
108 "Gamma in kernel function (only for polynomial and radial basis kernels). When set to zero, the default value will actually be 1/k, where k is the number of layers.",
109 "Gamma in kernel function (only for polynomial and radial basis kernels). When set to zero, the default value will actually be 1/k, where k is the number of layers.",
121 "Coef0 in kernel function (only for polynomial kernels).",
122 "Coef0 in kernel function (only for polynomial kernels).",
134 "Cost (only for C-SVC types).",
135 "Cost (only for C-SVC types).",
147 "Nu (only for Nu-SVC and one-class SVM).",
148 "Nu (only for Nu-SVC and one-class SVM).",
158 "Probabilistic output",
160 "Indicates if the output should be a probability instead of a binary response (only available for C-SVC and Nu-SVC).",
161 "Indicates if the output should be a probability instead of a binary response (only available for C-SVC and Nu-SVC).",
171 "Number of pseudo-absences",
173 "Number of pseudo-absences to be generated (only for C-SVC and Nu-SVC when no absences have been provided). When absences are needed, a zero parameter will default to the same number of presences.",
174 "Number of pseudo-absences to be generated (only for C-SVC and Nu-SVC when no absences have been provided). When absences are needed, a zero parameter will default to the same number of presences.",
189 "SVM (Support Vector Machines)",
193 "Support vector machines (SVMs) are a set of related supervised learning methods that belong to a family of generalized linear classifiers. They can also be considered a special case of Tikhonov regularization. A special property of SVMs is that they simultaneously minimize the empirical classification error and maximize the geometric margin; hence they are also known as maximum margin classifiers. Content retrieved from Wikipedia on the 13th of June, 2007: http://en.wikipedia.org/w/index.php?title=Support_vector_machine&oldid=136646498.",
196 "Support vector machines map input vectors to a higher dimensional space where a maximal separating hyperplane is constructed. Two parallel hyperplanes are constructed on each side of the hyperplane that separates the data. The separating hyperplane is the hyperplane that maximises the distance between the two parallel hyperplanes. An assumption is made that the larger the margin or distance between these parallel hyperplanes the better the generalisation error of the classifier will be. The model produced by support vector classification only depends on a subset of the training data, because the cost function for building the model does not care about training points that lie beyond the margin. Content retrieved from Wikipedia on the 13th of June, 2007: http://en.wikipedia.org/w/index.php?title=Support_vector_machine&oldid=136646498. The openModeller implementation of SVMs makes use of the libsvm library version 2.85: Chih-Chung Chang and Chih-Jen Lin, LIBSVM: a library for support vector machines, 2001. Software available at http://www.csie.ntu.edu.tw/~cjlin/libsvm.\n\nRelease history:\n version 0.1: initial release\n version 0.2: New parameter to specify the number of pseudo-absences to be generated; upgraded to libsvm 2.85; fixed memory leaks\n version 0.3: when absences are needed and the number of pseudo absences to be generated is zero, it will default to the same number of presences\n version 0.4: included missing serialization of C\n version 0.5: the indication if the algorithm needed normalized environmental data was not working when the algorithm was loaded from an existing model.",
198 "Vladimir N. Vapnik",
199 "1) Vapnik, V. (1995) The Nature of Statistical Learning Theory. SpringerVerlag. 2) Schölkopf, B., Smola, A., Williamson, R. and Bartlett, P.L.(2000). New support vector algorithms. Neural Computation, 12, 1207-1245. 3) Schölkopf, B., Platt, J.C., Shawe-Taylor, J., Smola A.J. and Williamson, R.C. (2001). Estimating the support of a high-dimensional distribution. Neural Computation, 13, 1443-1471. 4) Cristianini, N. & Shawe-Taylor, J. (2000). An Introduction to Support Vector Machines and other kernel-based learning methods. Cambridge University Press.",
201 "Renato De Giovanni in collaboration with Ana Carolina Lorena",
202 "renato [at] cria . org . br",
265 _presence_index( -1 )
441 int num_presences =
_samp->numPresence();
443 if ( num_presences == 0 ) {
449 int num_absences =
_samp->numAbsence();
451 bool generate_pseudo_absences =
false;
463 num_absences = num_presences;
465 else if ( num_absences == 0 ) {
469 num_absences = num_presences;
471 else if ( num_absences < 0 ) {
477 generate_pseudo_absences =
true;
480 int num_points = num_presences;
485 num_points += num_absences;
508 if ( generate_pseudo_absences ) {
512 absences =
new OccurrencesImpl( presences->label(), presences->coordSystem() );
514 for (
int i = 0; i < num_absences; ++i ) {
517 absences->insert( oc );
532 absences =
_samp->getAbsences();
535 p_iterator = absences->begin();
536 p_end = absences->end();
538 while ( p_iterator != p_end ) {
540 Sample point = (*p_iterator)->environment();
555 p_iterator = presences->begin();
556 p_end = presences->end();
558 while ( p_iterator != p_end ) {
560 Sample point = (*p_iterator)->environment();
573 const char *error_msg;
599 int * labels =
new int[2];
639 double * estimates =
new double[2];
641 svm_predict_probability(
_svm_model, node, estimates );
651 double class_predicted = svm_predict(
_svm_model, node );
653 prob = ( class_predicted < 0.0 ) ? 0 : 1;
678 node[j].value = sample[j];
694 config->addSubsection( model_config );
696 model_config->addNameValue(
"NumLayers",
_num_layers );
698 model_config->addNameValue(
"KernelType",
_svm_parameter.kernel_type );
699 model_config->addNameValue(
"Probabilistic",
_svm_parameter.probability );
718 model_config->addSubsection( vectors_config );
720 vectors_config->addNameValue(
"Total",
_svm_model->
l );
723 int * labels =
new int[2];
727 model_config->addNameValue(
"Labels", labels, 2 );
738 vectors_config->addSubsection( vector_config );
740 vector_config->addNameValue(
"Coef", sv_coef[0][i] );
742 const svm_node *p = SV[i];
744 while ( p->index != -1 ) {
747 vector_config->addSubsection( node_config );
749 node_config->addNameValue(
"Index", p->index );
750 node_config->addNameValue(
"Value", p->value );
762 if ( ! model_config )
772 _num_layers = model_config->getAttributeAsInt(
"NumLayers", 0 );
773 _svm_parameter.svm_type = model_config->getAttributeAsInt(
"Type", 0 );
774 _svm_parameter.kernel_type = model_config->getAttributeAsInt(
"KernelType", 2 );
775 _svm_parameter.probability = model_config->getAttributeAsInt(
"Probabilistic", 1 );
776 _svm_parameter.degree = model_config->getAttributeAsInt(
"Degree", 3 );
777 _svm_parameter.gamma = model_config->getAttributeAsDouble(
"Gamma", 0 );
778 _svm_parameter.coef0 = model_config->getAttributeAsDouble(
"Coef0", 0 );
802 _svm_model->
rho[0] = model_config->getAttributeAsDouble(
"Rho", 0.0 );
809 _svm_model->
probA[0] = model_config->getAttributeAsDouble(
"ProbA", 0.0 );
810 _svm_model->
probB[0] = model_config->getAttributeAsDouble(
"ProbB", 0.0 );
816 model_config->getAttributeAsIntArray(
"NrSv", &
_svm_model->
nSV, &size );
821 _svm_model->
l = vectors_config->getAttributeAsInt(
"Total", 0 );
825 Configuration::subsection_list::iterator vec = vectors.begin();
826 Configuration::subsection_list::iterator last_vec = vectors.end();
835 for ( ; vec != last_vec; ++vec ) {
837 if ( (*vec)->getName() !=
"Vector" ) {
848 Configuration::subsection_list::iterator node = nodes.begin();
849 Configuration::subsection_list::iterator last_node = nodes.end();
853 for ( ; node != last_node; ++node ) {
855 if ( (*node)->getName() !=
"Node" ) {
860 _svm_model->
SV[i][j].index = (*node)->getAttributeAsInt(
"Index", 0 );
861 _svm_model->
SV[i][j].value = (*node)->getAttributeAsDouble(
"Value", 0.0 );
874 model_config->getAttributeAsIntArray(
"Labels", &
_svm_model->
label, &size );
void _getConfiguration(ConfigurationPtr &) const
void warn(const char *format,...)
'Warn' level.
std::vector< ConfigurationPtr > subsection_list
void _getNode(svm_node *node, const Sample &sample) const
double Scalar
Type of map values.
static AlgMetadata metadata
static Log * instance()
Returns the instance pointer, creating the object on the first call.
static AlgParamMetadata parameters[NUM_PARAM]
SamplerPtr createSampler(const EnvironmentPtr &env, const OccurrencesPtr &presence, const OccurrencesPtr &absence)
void error(const char *format,...)
'Error' level.
OM_ALG_DLL_EXPORT AlgMetadata const * algorithmMetadata()
int getParameter(std::string const &name, std::string *value)
void setNormalization(const SamplerPtr &samp) const
OM_ALG_DLL_EXPORT AlgorithmImpl * algorithmFactory()
int getConvergence(Scalar *const val) const
void info(const char *format,...)
'Info' level.
void _setConfiguration(const ConstConfigurationPtr &)
std::vector< OccurrencePtr >::const_iterator const_iterator
svm_parameter _svm_parameter
virtual void computeNormalization(const ReferenceCountedPointer< const SamplerImpl > &samplerPtr)=0
Scalar getValue(const Sample &x) const
Normalizer * _normalizerPtr