svm.h
Go to the documentation of this file.
00001 #ifndef _LIBSVM_H
00002 #define _LIBSVM_H
00003 
00004 #define LIBSVM_VERSION 300
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     unsigned char *SVidx;
00072     //int nx;
00073 };
00074 
00075 struct svm_model *svm_train(const struct svm_problem *prob, const struct svm_parameter *param);
00076 void svm_cross_validation(const struct svm_problem *prob, const struct svm_parameter *param, int nr_fold, double *target);
00077 
00078 int svm_save_model(const char *model_file_name, const struct svm_model *model);
00079 struct svm_model *svm_load_model(const char *model_file_name);
00080 
00081 int svm_get_svm_type(const struct svm_model *model);
00082 int svm_get_nr_class(const struct svm_model *model);
00083 void svm_get_labels(const struct svm_model *model, int *label);
00084 void svm_get_support_vectors(const svm_model *model, int nx, int* sv);
00085 double svm_get_svr_probability(const struct svm_model *model);
00086 
00087 double svm_predict_values(const struct svm_model *model, const struct svm_node *x, double* dec_values);
00088 double svm_predict(const struct svm_model *model, const struct svm_node *x);
00089 double svm_predict_probability(const struct svm_model *model, const struct svm_node *x, double* prob_estimates);
00090 
00091 void svm_free_model_content(struct svm_model *model_ptr);
00092 void svm_free_and_destroy_model(struct svm_model **model_ptr_ptr);
00093 void svm_destroy_param(struct svm_parameter *param);
00094 
00095 const char *svm_check_parameter(const struct svm_problem *prob, const struct svm_parameter *param);
00096 int svm_check_probability_model(const struct svm_model *model);
00097 
00098 void svm_set_print_string_function(void (*print_func)(const char *));
00099 
00100 // deprecated
00101 // this function will be removed in future release
00102 void svm_destroy_model(struct svm_model *model_ptr); 
00103 
00104 #ifdef __cplusplus
00105 }
00106 #endif
00107 
00108 #endif /* _LIBSVM_H */


libsvm3
Author(s): various
autogenerated on Wed Nov 27 2013 11:36:23