svm.h
Go to the documentation of this file.
00001 #ifndef _LIBSVM_H
00002 #define _LIBSVM_H
00003 
00004 #define LIBSVM_VERSION 312
00005 
00006 #ifdef __cplusplus
00007 extern "C" {
00008 #endif
00009 
00010 extern int libsvm_version;
00011 
00012 struct svm_node
00013 {
00014         int index;
00015         double value;
00016 };
00017 
00018 struct svm_problem
00019 {
00020         int l;
00021         double *y;
00022         struct svm_node **x;
00023 };
00024 
00025 enum { C_SVC, NU_SVC, ONE_CLASS, EPSILON_SVR, NU_SVR }; /* svm_type */
00026 enum { LINEAR, POLY, RBF, SIGMOID, PRECOMPUTED }; /* kernel_type */
00027 
00028 struct svm_parameter
00029 {
00030         int svm_type;
00031         int kernel_type;
00032         int degree;     /* for poly */
00033         double gamma;   /* for poly/rbf/sigmoid */
00034         double coef0;   /* for poly/sigmoid */
00035 
00036         /* these are for training only */
00037         double cache_size; /* in MB */
00038         double eps;     /* stopping criteria */
00039         double C;       /* for C_SVC, EPSILON_SVR and NU_SVR */
00040         int nr_weight;          /* for C_SVC */
00041         int *weight_label;      /* for C_SVC */
00042         double* weight;         /* for C_SVC */
00043         double nu;      /* for NU_SVC, ONE_CLASS, and NU_SVR */
00044         double p;       /* for EPSILON_SVR */
00045         int shrinking;  /* use the shrinking heuristics */
00046         int probability; /* do probability estimates */
00047 };
00048 
00049 //
00050 // svm_model
00051 // 
00052 struct svm_model
00053 {
00054         struct svm_parameter param;     /* parameter */
00055         int nr_class;           /* number of classes, = 2 in regression/one class svm */
00056         int l;                  /* total #SV */
00057         struct svm_node **SV;           /* SVs (SV[l]) */
00058         double **sv_coef;       /* coefficients for SVs in decision functions (sv_coef[k-1][l]) */
00059         double *rho;            /* constants in decision functions (rho[k*(k-1)/2]) */
00060         double *probA;          /* pariwise probability information */
00061         double *probB;
00062 
00063         /* for classification only */
00064 
00065         int *label;             /* label of each class (label[k]) */
00066         int *nSV;               /* number of SVs for each class (nSV[k]) */
00067                                 /* nSV[0] + nSV[1] + ... + nSV[k-1] = l */
00068         /* XXX */
00069         int free_sv;            /* 1 if svm_model is created by svm_load_model*/
00070                                 /* 0 if svm_model is created by svm_train */
00071 };
00072 
00073 struct svm_model *svm_train(const struct svm_problem *prob, const struct svm_parameter *param);
00074 void svm_cross_validation(const struct svm_problem *prob, const struct svm_parameter *param, int nr_fold, double *target);
00075 
00076 int svm_save_model(const char *model_file_name, const struct svm_model *model);
00077 struct svm_model *svm_load_model(const char *model_file_name);
00078 
00079 int svm_get_svm_type(const struct svm_model *model);
00080 int svm_get_nr_class(const struct svm_model *model);
00081 void svm_get_labels(const struct svm_model *model, int *label);
00082 double svm_get_svr_probability(const struct svm_model *model);
00083 
00084 double svm_predict_values(const struct svm_model *model, const struct svm_node *x, double* dec_values);
00085 double svm_predict(const struct svm_model *model, const struct svm_node *x);
00086 double svm_predict_probability(const struct svm_model *model, const struct svm_node *x, double* prob_estimates);
00087 
00088 void svm_free_model_content(struct svm_model *model_ptr);
00089 void svm_free_and_destroy_model(struct svm_model **model_ptr_ptr);
00090 void svm_destroy_param(struct svm_parameter *param);
00091 
00092 const char *svm_check_parameter(const struct svm_problem *prob, const struct svm_parameter *param);
00093 int svm_check_probability_model(const struct svm_model *model);
00094 
00095 void svm_set_print_string_function(void (*print_func)(const char *));
00096 
00097 #ifdef __cplusplus
00098 }
00099 #endif
00100 
00101 #endif /* _LIBSVM_H */


haf_grasping
Author(s): David Fischinger
autogenerated on Wed Jan 11 2017 03:48:49