SVM_libsvm.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00037
00038 #ifndef _LIBSVM_H
00039 #define _LIBSVM_H
00040
00041 #include "kernel/Kernel.h"
00042
00043 namespace shogun
00044 {
00046 struct svm_node
00047 {
00049 int32_t index;
00050 };
00051
00053 struct svm_problem
00054 {
00055
00056
00057 public:
00058
00060 svm_problem() {
00061 y = NULL;
00062 x = NULL;
00063 C = NULL;
00064 pv = NULL;
00065 }
00066
00067
00069 int32_t l;
00071 float64_t *y;
00073 struct svm_node **x;
00075 float64_t *C;
00077 float64_t *pv;
00078
00079 };
00080
00081 enum { C_SVC=1, NU_SVC=2, NU_MULTICLASS_SVC=3, ONE_CLASS=4, EPSILON_SVR=5, NU_SVR=6 };
00082 enum { LINEAR, POLY, RBF, SIGMOID, PRECOMPUTED };
00083
00085 struct svm_parameter
00086 {
00088 int32_t svm_type;
00090 int32_t kernel_type;
00092 shogun::CKernel* kernel;
00094 int32_t degree;
00096 float64_t gamma;
00098 float64_t coef0;
00099
00100
00102 float64_t cache_size;
00104 float64_t eps;
00106 float64_t C;
00108 int32_t nr_class;
00110 int32_t nr_weight;
00112 int32_t *weight_label;
00114 float64_t* weight;
00116 float64_t nu;
00118 float64_t p;
00120 int32_t shrinking;
00122 bool use_bias;
00123 };
00124
00126 struct svm_model
00127 {
00129 svm_parameter param;
00131 int32_t nr_class;
00133 int32_t l;
00135 svm_node **SV;
00137 float64_t **sv_coef;
00139 float64_t *rho;
00141 float64_t *normwcw;
00142
00143
00144
00146 int32_t *label;
00150 int32_t *nSV;
00151
00155 int32_t free_sv;
00157 float64_t objective;
00158 };
00159
00160
00161
00162 struct svm_model *svm_train(
00163 const struct svm_problem *prob, const struct svm_parameter *param);
00164
00165 float64_t svm_predict(const struct svm_model *model, const struct svm_node *x);
00166
00167 void svm_destroy_model(struct svm_model *model);
00168
00169 const char *svm_check_parameter(const struct svm_problem *prob, const struct svm_parameter *param);
00170 }
00171 #endif
00172
00173 #endif // DOXYGEN_SHOULD_SKIP_THIS