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 };
00026 enum { LINEAR, POLY, RBF, SIGMOID, PRECOMPUTED };
00027
00028 struct svm_parameter
00029 {
00030 int svm_type;
00031 int kernel_type;
00032 int degree;
00033 double gamma;
00034 double coef0;
00035
00036
00037 double cache_size;
00038 double eps;
00039 double C;
00040 int nr_weight;
00041 int *weight_label;
00042 double* weight;
00043 double nu;
00044 double p;
00045 int shrinking;
00046 int probability;
00047 };
00048
00049
00050
00051
00052 struct svm_model
00053 {
00054 struct svm_parameter param;
00055 int nr_class;
00056 int l;
00057 struct svm_node **SV;
00058 double **sv_coef;
00059 double *rho;
00060 double *probA;
00061 double *probB;
00062
00063
00064
00065 int *label;
00066 int *nSV;
00067
00068
00069 int free_sv;
00070
00071 unsigned char *SVidx;
00072
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
00101
00102 void svm_destroy_model(struct svm_model *model_ptr);
00103
00104 #ifdef __cplusplus
00105 }
00106 #endif
00107
00108 #endif