00001 #ifndef _LIBSVM_H
00002 #define _LIBSVM_H
00003
00004 #ifdef __cplusplus
00005 extern "C" {
00006 #endif
00007
00008 struct svm_node
00009 {
00010 int index;
00011 double value;
00012 };
00013
00014 struct svm_problem
00015 {
00016 int l;
00017 double *y;
00018 struct svm_node **x;
00019 };
00020
00021 enum { C_SVC, NU_SVC, ONE_CLASS, EPSILON_SVR, NU_SVR };
00022 enum { LINEAR, POLY, RBF, SIGMOID };
00023
00024 struct svm_parameter
00025 {
00026 int svm_type;
00027 int kernel_type;
00028 double degree;
00029 double gamma;
00030 double coef0;
00031
00032
00033 double cache_size;
00034 double eps;
00035 double C;
00036 int nr_weight;
00037 int *weight_label;
00038 double* weight;
00039 double nu;
00040 double p;
00041 int shrinking;
00042 int probability;
00043 };
00044
00045 struct svm_model *svm_train(const struct svm_problem *prob, const struct svm_parameter *param);
00046 void svm_cross_validation(const struct svm_problem *prob, const struct svm_parameter *param, int nr_fold, double *target);
00047
00048 int svm_save_model(const char *model_file_name, const struct svm_model *model);
00049 struct svm_model *svm_load_model(const char *model_file_name);
00050
00051 int svm_get_svm_type(const struct svm_model *model);
00052 int svm_get_nr_class(const struct svm_model *model);
00053 void svm_get_labels(const struct svm_model *model, int *label);
00054 double svm_get_svr_probability(const struct svm_model *model);
00055
00056 void svm_predict_values(const struct svm_model *model, const struct svm_node *x, double* dec_values);
00057 double svm_predict(const struct svm_model *model, const struct svm_node *x);
00058 double svm_predict_probability(const struct svm_model *model, const struct svm_node *x, double* prob_estimates);
00059
00060 void svm_destroy_model(struct svm_model *model);
00061 void svm_destroy_param(struct svm_parameter *param);
00062
00063 const char *svm_check_parameter(const struct svm_problem *prob, const struct svm_parameter *param);
00064 int svm_check_probability_model(const struct svm_model *model);
00065
00066 #ifdef __cplusplus
00067 }
00068 #endif
00069
00070 #endif