6560
|
1 /* |
|
2 |
12591
|
3 Copyright (c) 2007-2011 The LIBLINEAR Project. |
|
4 Copyright (c) 2010,2015 Alois Schloegl <alois.schloegl@ist.ac.at> |
6560
|
5 This function is part of the NaN-toolbox |
7889
|
6 http://pub.ist.ac.at/~schloegl/matlab/NaN/ |
6560
|
7 |
12591
|
8 This code was extracted from liblinear-1.8 in Apr 2015 and |
6560
|
9 modified for the use with Octave |
|
10 |
|
11 This program is free software; you can redistribute it and/or modify |
|
12 it under the terms of the GNU General Public License as published by |
|
13 the Free Software Foundation; either version 3 of the License, or |
|
14 (at your option) any later version. |
|
15 |
|
16 This program is distributed in the hope that it will be useful, |
|
17 but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
19 GNU General Public License for more details. |
|
20 |
|
21 You should have received a copy of the GNU General Public License |
|
22 along with this program; if not, see <http://www.gnu.org/licenses/>. |
|
23 |
|
24 */ |
|
25 |
|
26 #ifndef _LIBLINEAR_H |
|
27 #define _LIBLINEAR_H |
|
28 |
|
29 #ifdef __cplusplus |
|
30 extern "C" { |
|
31 #endif |
|
32 |
|
33 struct feature_node |
|
34 { |
|
35 int index; |
|
36 double value; |
|
37 }; |
|
38 |
|
39 struct problem |
|
40 { |
|
41 int l, n; |
|
42 int *y; |
|
43 struct feature_node **x; |
|
44 double bias; /* < 0 if no bias term */ |
|
45 }; |
|
46 |
12591
|
47 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 */ |
6560
|
48 |
|
49 struct parameter |
|
50 { |
|
51 int solver_type; |
|
52 |
|
53 /* these are for training only */ |
|
54 double eps; /* stopping criteria */ |
|
55 double C; |
|
56 int nr_weight; |
|
57 int *weight_label; |
|
58 double* weight; |
|
59 }; |
|
60 |
|
61 struct model |
|
62 { |
|
63 struct parameter param; |
|
64 int nr_class; /* number of classes */ |
|
65 int nr_feature; |
|
66 double *w; |
|
67 int *label; /* label of each class */ |
|
68 double bias; |
|
69 }; |
|
70 |
|
71 struct model* train(const struct problem *prob, const struct parameter *param); |
|
72 void cross_validation(const struct problem *prob, const struct parameter *param, int nr_fold, int *target); |
|
73 |
|
74 int predict_values(const struct model *model_, const struct feature_node *x, double* dec_values); |
|
75 int predict(const struct model *model_, const struct feature_node *x); |
|
76 int predict_probability(const struct model *model_, const struct feature_node *x, double* prob_estimates); |
|
77 |
|
78 int save_model(const char *model_file_name, const struct model *model_); |
|
79 struct model *load_model(const char *model_file_name); |
|
80 |
|
81 int get_nr_feature(const struct model *model_); |
|
82 int get_nr_class(const struct model *model_); |
|
83 void get_labels(const struct model *model_, int* label); |
|
84 |
12591
|
85 void free_model_content(struct model *model_ptr); |
|
86 void free_and_destroy_model(struct model **model_ptr_ptr); |
6560
|
87 void destroy_param(struct parameter *param); |
12591
|
88 |
|
89 const char *check_parameter(const struct problem *prob, const struct parameter *param); |
|
90 int check_probability_model(const struct model *model); |
|
91 void set_print_string_function(void (*print_func) (const char*)); |
6560
|
92 |
|
93 #ifdef __cplusplus |
|
94 } |
|
95 #endif |
|
96 |
|
97 #endif /* _LIBLINEAR_H */ |
|
98 |