]> granicus.if.org Git - liblinear/blob - linear.h
Remove unused parameter
[liblinear] / linear.h
1 #ifndef _LIBLINEAR_H
2 #define _LIBLINEAR_H
3
4 #define LIBLINEAR_VERSION 241
5
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9
10 extern int liblinear_version;
11
12 struct feature_node
13 {
14         int index;
15         double value;
16 };
17
18 struct problem
19 {
20         int l, n;
21         double *y;
22         struct feature_node **x;
23         double bias;            /* < 0 if no bias term */
24 };
25
26 enum { L2R_LR, L2R_L2LOSS_SVC_DUAL, L2R_L2LOSS_SVC, L2R_L1LOSS_SVC_DUAL, MCSVM_CS, L1R_L2LOSS_SVC, L1R_LR, L2R_LR_DUAL, L2R_L2LOSS_SVR = 11, L2R_L2LOSS_SVR_DUAL, L2R_L1LOSS_SVR_DUAL, ONECLASS_SVM = 21 }; /* solver_type */
27
28 struct parameter
29 {
30         int solver_type;
31
32         /* these are for training only */
33         double eps;             /* stopping criteria */
34         double C;
35         int nr_weight;
36         int *weight_label;
37         double* weight;
38         double p;
39         double nu;
40         double *init_sol;
41         int regularize_bias;
42 };
43
44 struct model
45 {
46         struct parameter param;
47         int nr_class;           /* number of classes */
48         int nr_feature;
49         double *w;
50         int *label;             /* label of each class */
51         double bias;
52         double rho;             /* one-class SVM only */
53 };
54
55 struct model* train(const struct problem *prob, const struct parameter *param);
56 void cross_validation(const struct problem *prob, const struct parameter *param, int nr_fold, double *target);
57 void find_parameters(const struct problem *prob, const struct parameter *param, int nr_fold, double start_C, double start_p, double *best_C, double *best_p, double *best_score);
58
59 double predict_values(const struct model *model_, const struct feature_node *x, double* dec_values);
60 double predict(const struct model *model_, const struct feature_node *x);
61 double predict_probability(const struct model *model_, const struct feature_node *x, double* prob_estimates);
62
63 int save_model(const char *model_file_name, const struct model *model_);
64 struct model *load_model(const char *model_file_name);
65
66 int get_nr_feature(const struct model *model_);
67 int get_nr_class(const struct model *model_);
68 void get_labels(const struct model *model_, int* label);
69 double get_decfun_coef(const struct model *model_, int feat_idx, int label_idx);
70 double get_decfun_bias(const struct model *model_, int label_idx);
71 double get_decfun_rho(const struct model *model_);
72
73 void free_model_content(struct model *model_ptr);
74 void free_and_destroy_model(struct model **model_ptr_ptr);
75 void destroy_param(struct parameter *param);
76
77 const char *check_parameter(const struct problem *prob, const struct parameter *param);
78 int check_probability_model(const struct model *model);
79 int check_regression_model(const struct model *model);
80 int check_oneclass_model(const struct model *model);
81 void set_print_string_function(void (*print_func) (const char*));
82
83 #ifdef __cplusplus
84 }
85 #endif
86
87 #endif /* _LIBLINEAR_H */
88