svm.h
Go to the documentation of this file.
1 #ifndef _LIBSVM_H
2 #define _LIBSVM_H
3 
4 #define LIBSVM_VERSION 312
5 
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 
10 extern int libsvm_version;
11 
12 struct svm_node
13 {
14  int index;
15  double value;
16 };
17 
19 {
20  int l;
21  double *y;
22  struct svm_node **x;
23 };
24 
25 enum { C_SVC, NU_SVC, ONE_CLASS, EPSILON_SVR, NU_SVR }; /* svm_type */
26 enum { LINEAR, POLY, RBF, SIGMOID, PRECOMPUTED }; /* kernel_type */
27 
29 {
30  int svm_type;
32  int degree; /* for poly */
33  double gamma; /* for poly/rbf/sigmoid */
34  double coef0; /* for poly/sigmoid */
35 
36  /* these are for training only */
37  double cache_size; /* in MB */
38  double eps; /* stopping criteria */
39  double C; /* for C_SVC, EPSILON_SVR and NU_SVR */
40  int nr_weight; /* for C_SVC */
41  int *weight_label; /* for C_SVC */
42  double* weight; /* for C_SVC */
43  double nu; /* for NU_SVC, ONE_CLASS, and NU_SVR */
44  double p; /* for EPSILON_SVR */
45  int shrinking; /* use the shrinking heuristics */
46  int probability; /* do probability estimates */
47 };
48 
49 //
50 // svm_model
51 //
52 struct svm_model
53 {
54  struct svm_parameter param; /* parameter */
55  int nr_class; /* number of classes, = 2 in regression/one class svm */
56  int l; /* total #SV */
57  struct svm_node **SV; /* SVs (SV[l]) */
58  double **sv_coef; /* coefficients for SVs in decision functions (sv_coef[k-1][l]) */
59  double *rho; /* constants in decision functions (rho[k*(k-1)/2]) */
60  double *probA; /* pariwise probability information */
61  double *probB;
62 
63  /* for classification only */
64 
65  int *label; /* label of each class (label[k]) */
66  int *nSV; /* number of SVs for each class (nSV[k]) */
67  /* nSV[0] + nSV[1] + ... + nSV[k-1] = l */
68  /* XXX */
69  int free_sv; /* 1 if svm_model is created by svm_load_model*/
70  /* 0 if svm_model is created by svm_train */
71 };
72 
73 struct svm_model *svm_train(const struct svm_problem *prob, const struct svm_parameter *param);
74 void svm_cross_validation(const struct svm_problem *prob, const struct svm_parameter *param, int nr_fold, double *target);
75 
76 int svm_save_model(const char *model_file_name, const struct svm_model *model);
77 struct svm_model *svm_load_model(const char *model_file_name);
78 
79 int svm_get_svm_type(const struct svm_model *model);
80 int svm_get_nr_class(const struct svm_model *model);
81 void svm_get_labels(const struct svm_model *model, int *label);
82 double svm_get_svr_probability(const struct svm_model *model);
83 
84 double svm_predict_values(const struct svm_model *model, const struct svm_node *x, double* dec_values);
85 double svm_predict(const struct svm_model *model, const struct svm_node *x);
86 double svm_predict_probability(const struct svm_model *model, const struct svm_node *x, double* prob_estimates);
87 
88 void svm_free_model_content(struct svm_model *model_ptr);
89 void svm_free_and_destroy_model(struct svm_model **model_ptr_ptr);
91 
92 const char *svm_check_parameter(const struct svm_problem *prob, const struct svm_parameter *param);
94 
95 void svm_set_print_string_function(void (*print_func)(const char *));
96 
97 #ifdef __cplusplus
98 }
99 #endif
100 
101 #endif /* _LIBSVM_H */
svm_check_parameter
const char * svm_check_parameter(const struct svm_problem *prob, const struct svm_parameter *param)
svm_problem::y
double * y
Definition: svm.h:21
subset.label
label
Definition: subset.py:57
svm_model::rho
double * rho
Definition: svm.h:59
svm_get_labels
void svm_get_labels(const struct svm_model *model, int *label)
svm_check_probability_model
int svm_check_probability_model(const struct svm_model *model)
model
struct svm_model * model
Definition: svmtrain.c:58
svm_model::nSV
int * nSV
Definition: svm.h:66
svm_parameter::weight_label
int * weight_label
Definition: svm.h:41
svm_parameter::kernel_type
int kernel_type
Definition: svm.h:31
libsvm_version
int libsvm_version
Definition: svm.cpp:11
svm_parameter::eps
double eps
Definition: svm.h:38
svm_predict_values
double svm_predict_values(const struct svm_model *model, const struct svm_node *x, double *dec_values)
svm_model::l
int l
Definition: svm.h:56
svm_node::index
int index
Definition: svm.h:14
svm_problem::l
int l
Definition: svm.h:20
svm_parameter::C
double C
Definition: svm.h:39
svm_model::probA
double * probA
Definition: svm.h:60
LINEAR
@ LINEAR
Definition: svm.h:26
svm_node
Definition: svm.h:12
svm_parameter::cache_size
double cache_size
Definition: svm.h:37
EPSILON_SVR
@ EPSILON_SVR
Definition: svm.h:25
svm_model::label
int * label
Definition: svm.h:65
svm_model::SV
struct svm_node ** SV
Definition: svm.h:57
svm_parameter::coef0
double coef0
Definition: svm.h:34
svm_problem
Definition: svm.h:18
svm_predict
double svm_predict(const struct svm_model *model, const struct svm_node *x)
POLY
@ POLY
Definition: svm.h:26
svm_model::sv_coef
double ** sv_coef
Definition: svm.h:58
svm_parameter::probability
int probability
Definition: svm.h:46
svm_parameter
Definition: svm.h:28
svm_model::nr_class
int nr_class
Definition: svm.h:55
svm_parameter::gamma
double gamma
Definition: svm.h:33
svm_cross_validation
void svm_cross_validation(const struct svm_problem *prob, const struct svm_parameter *param, int nr_fold, double *target)
svm_parameter::nr_weight
int nr_weight
Definition: svm.h:40
svm_model::param
struct svm_parameter param
Definition: svm.h:54
svm_parameter::nu
double nu
Definition: svm.h:43
svm_get_svm_type
int svm_get_svm_type(const struct svm_model *model)
RBF
@ RBF
Definition: svm.h:26
svm_save_model
int svm_save_model(const char *model_file_name, const struct svm_model *model)
svm_parameter::degree
int degree
Definition: svm.h:32
nr_fold
int nr_fold
Definition: svmtrain.c:61
x
struct svm_node * x
Definition: svm-predict.c:8
svm_problem::x
struct svm_node ** x
Definition: svm.h:22
PRECOMPUTED
@ PRECOMPUTED
Definition: svm.h:26
svm_set_print_string_function
void svm_set_print_string_function(void(*print_func)(const char *))
Definition: svm.cpp:3106
NU_SVC
@ NU_SVC
Definition: svm.h:25
C_SVC
@ C_SVC
Definition: svm.h:25
svm_parameter::svm_type
int svm_type
Definition: svm.h:30
svm_node::value
double value
Definition: svm.h:15
svm_parameter::weight
double * weight
Definition: svm.h:42
svm_parameter::p
double p
Definition: svm.h:44
svm_model::free_sv
int free_sv
Definition: svm.h:69
svm_load_model
struct svm_model * svm_load_model(const char *model_file_name)
Definition: svm.cpp:2714
svm_train
struct svm_model * svm_train(const struct svm_problem *prob, const struct svm_parameter *param)
prob
struct svm_problem prob
Definition: svmtrain.c:57
svm_model
Definition: svm.h:52
SIGMOID
@ SIGMOID
Definition: svm.h:26
svm_parameter::shrinking
int shrinking
Definition: svm.h:45
svm_destroy_param
void svm_destroy_param(struct svm_parameter *param)
Definition: svm.cpp:2971
svm_predict_probability
double svm_predict_probability(const struct svm_model *model, const struct svm_node *x, double *prob_estimates)
svm_free_model_content
void svm_free_model_content(struct svm_model *model_ptr)
Definition: svm.cpp:2929
svm_free_and_destroy_model
void svm_free_and_destroy_model(struct svm_model **model_ptr_ptr)
Definition: svm.cpp:2961
svm_model::probB
double * probB
Definition: svm.h:61
param
struct svm_parameter param
Definition: svmtrain.c:56
svm_get_nr_class
int svm_get_nr_class(const struct svm_model *model)
ONE_CLASS
@ ONE_CLASS
Definition: svm.h:25
svm_get_svr_probability
double svm_get_svr_probability(const struct svm_model *model)
NU_SVR
@ NU_SVR
Definition: svm.h:25


haf_grasping
Author(s): David Fischinger
autogenerated on Sat Apr 1 2023 02:23:27