svm.h

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 }; /* svm_type */
00022 enum { LINEAR, POLY, RBF, SIGMOID };    /* kernel_type */
00023 
00024 struct svm_parameter
00025 {
00026         int svm_type;
00027         int kernel_type;
00028         double degree;  /* for poly */
00029         double gamma;   /* for poly/rbf/sigmoid */
00030         double coef0;   /* for poly/sigmoid */
00031 
00032         /* these are for training only */
00033         double cache_size; /* in MB */
00034         double eps;     /* stopping criteria */
00035         double C;       /* for C_SVC, EPSILON_SVR and NU_SVR */
00036         int nr_weight;          /* for C_SVC */
00037         int *weight_label;      /* for C_SVC */
00038         double* weight;         /* for C_SVC */
00039         double nu;      /* for NU_SVC, ONE_CLASS, and NU_SVR */
00040         double p;       /* for EPSILON_SVR */
00041         int shrinking;  /* use the shrinking heuristics */
00042         int probability; /* do probability estimates */
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 /* _LIBSVM_H */

Generated on Mon Jun 5 10:20:43 2006 for Intelligence.kdevelop by  doxygen 1.4.6