svm.h
Go to the documentation of this file.
00001 #ifndef _LIBSVM_H
00002 #define _LIBSVM_H
00003 
00004 #define LIBSVM_VERSION 314
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         int *sv_indices;        /* sv_indices[0,...,nSV-1] are values in [1,...,num_traning_data] to indicate SVs in the training set */
00063 
00064         /* for classification only */
00065 
00066         int *label;             /* label of each class (label[k]) */
00067         int *nSV;               /* number of SVs for each class (nSV[k]) */
00068                                 /* nSV[0] + nSV[1] + ... + nSV[k-1] = l */
00069         /* XXX */
00070         int free_sv;            /* 1 if svm_model is created by svm_load_model*/
00071                                 /* 0 if svm_model is created by svm_train */
00072 };
00073 
00074 struct svm_model *svm_train(const struct svm_problem *prob, const struct svm_parameter *param);
00075 void svm_cross_validation(const struct svm_problem *prob, const struct svm_parameter *param, int nr_fold, double *target);
00076 
00077 int svm_save_model(const char *model_file_name, const struct svm_model *model);
00078 struct svm_model *svm_load_model(const char *model_file_name);
00079 
00080 int svm_get_svm_type(const struct svm_model *model);
00081 int svm_get_nr_class(const struct svm_model *model);
00082 void svm_get_labels(const struct svm_model *model, int *label);
00083 void svm_get_sv_indices(const struct svm_model *model, int *sv_indices);
00084 int svm_get_nr_sv(const struct svm_model *model);
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 #ifdef __cplusplus
00101 }
00102 #endif
00103 
00104 #endif /* _LIBSVM_H */


ml_classifiers
Author(s): Scott Niekum
autogenerated on Mon Oct 6 2014 02:20:58