1 #ifndef _LIBLINEAR_H
2 #define _LIBLINEAR_H
3 
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7 
8 struct feature_node
9 {
10 	int index;
11 	double value;
12 };
13 
14 struct problem
15 {
16 	int l, n;
17 	int *y;
18 	struct feature_node **x;
19 	double bias;            /* < 0 if no bias term */
20 };
21 
22 enum { L2R_LR, L2R_L2LOSS_SVC_DUAL, L2R_L2LOSS_SVC, L2R_L1LOSS_SVC_DUAL, MCSVM_CS, L1R_L2LOSS_SVC, L1R_LR, L2R_LR_DUAL }; /* solver_type */
23 
24 struct parameter
25 {
26 	int solver_type;
27 
28 	/* these are for training only */
29 	double eps;	        /* stopping criteria */
30 	double C;
31 	int nr_weight;
32 	int *weight_label;
33 	double* weight;
34 };
35 
36 struct model
37 {
38 	struct parameter param;
39 	int nr_class;		/* number of classes */
40 	int nr_feature;
41 	double *w;
42 	int *label;		/* label of each class */
43 	double bias;
44 };
45 
46 struct model* train(const struct problem *prob, const struct parameter *param);
47 void cross_validation(const struct problem *prob, const struct parameter *param, int nr_fold, int *target);
48 
49 int predict_values(const struct model *model_, const struct feature_node *x, double* dec_values);
50 int predict(const struct model *model_, const struct feature_node *x);
51 int predict_probability(const struct model *model_, const struct feature_node *x, double* prob_estimates);
52 
53 int save_model(const char *model_file_name, const struct model *model_);
54 struct model *load_model(const char *model_file_name);
55 
56 int get_nr_feature(const struct model *model_);
57 int get_nr_class(const struct model *model_);
58 void get_labels(const struct model *model_, int* label);
59 
60 void free_model_content(struct model *model_ptr);
61 void free_and_destroy_model(struct model **model_ptr_ptr);
62 void destroy_param(struct parameter *param);
63 
64 const char *check_parameter(const struct problem *prob, const struct parameter *param);
65 int check_probability_model(const struct model *model);
66 void set_print_string_function(void (*print_func) (const char*));
67 
68 #ifdef __cplusplus
69 }
70 #endif
71 
72 #endif /* _LIBLINEAR_H */
73 
74