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 };
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 };
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