Mercurial > forge
annotate extra/NaN/src/linear.h @ 12706:01c5f2e1ec48 octave-forge
fix integer types - avoid compiler warnings
author | schloegl |
---|---|
date | Tue, 05 Jan 2016 10:00:14 +0000 |
parents | 0605cb0434ff |
children |
rev | line source |
---|---|
6560 | 1 /* |
2 | |
12593
0605cb0434ff
[nan] revert r12777:12778 use liblinear 1.5x - because v1.8 does not support weighted samples
schloegl
parents:
12591
diff
changeset
|
3 $Id$ |
0605cb0434ff
[nan] revert r12777:12778 use liblinear 1.5x - because v1.8 does not support weighted samples
schloegl
parents:
12591
diff
changeset
|
4 Copyright (c) 2007-2009 The LIBLINEAR Project. |
0605cb0434ff
[nan] revert r12777:12778 use liblinear 1.5x - because v1.8 does not support weighted samples
schloegl
parents:
12591
diff
changeset
|
5 Copyright (c) 2010 Alois Schloegl <alois.schloegl@gmail.com> |
6560 | 6 This function is part of the NaN-toolbox |
7889 | 7 http://pub.ist.ac.at/~schloegl/matlab/NaN/ |
6560 | 8 |
12593
0605cb0434ff
[nan] revert r12777:12778 use liblinear 1.5x - because v1.8 does not support weighted samples
schloegl
parents:
12591
diff
changeset
|
9 This code was extracted from liblinear-1.51 in Jan 2010 and |
6560 | 10 modified for the use with Octave |
11 | |
12 This program is free software; you can redistribute it and/or modify | |
13 it under the terms of the GNU General Public License as published by | |
14 the Free Software Foundation; either version 3 of the License, or | |
15 (at your option) any later version. | |
16 | |
17 This program is distributed in the hope that it will be useful, | |
18 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 GNU General Public License for more details. | |
21 | |
22 You should have received a copy of the GNU General Public License | |
23 along with this program; if not, see <http://www.gnu.org/licenses/>. | |
24 | |
25 */ | |
26 | |
27 #ifndef _LIBLINEAR_H | |
28 #define _LIBLINEAR_H | |
29 | |
30 #ifdef __cplusplus | |
31 extern "C" { | |
32 #endif | |
33 | |
34 struct feature_node | |
35 { | |
36 int index; | |
37 double value; | |
38 }; | |
39 | |
40 struct problem | |
41 { | |
42 int l, n; | |
43 int *y; | |
44 struct feature_node **x; | |
45 double bias; /* < 0 if no bias term */ | |
12593
0605cb0434ff
[nan] revert r12777:12778 use liblinear 1.5x - because v1.8 does not support weighted samples
schloegl
parents:
12591
diff
changeset
|
46 double *W; /* instance weight */ |
6560 | 47 }; |
48 | |
12593
0605cb0434ff
[nan] revert r12777:12778 use liblinear 1.5x - because v1.8 does not support weighted samples
schloegl
parents:
12591
diff
changeset
|
49 enum { L2R_LR, L2R_L2LOSS_SVC_DUAL, L2R_L2LOSS_SVC, L2R_L1LOSS_SVC_DUAL, MCSVM_CS, L1R_L2LOSS_SVC, L1R_LR }; /* solver_type */ |
6560 | 50 |
51 struct parameter | |
52 { | |
53 int solver_type; | |
54 | |
55 /* these are for training only */ | |
56 double eps; /* stopping criteria */ | |
57 double C; | |
58 int nr_weight; | |
59 int *weight_label; | |
60 double* weight; | |
61 }; | |
62 | |
63 struct model | |
64 { | |
65 struct parameter param; | |
12706 | 66 unsigned nr_class; /* number of classes */ |
6560 | 67 int nr_feature; |
68 double *w; | |
69 int *label; /* label of each class */ | |
70 double bias; | |
71 }; | |
72 | |
73 struct model* train(const struct problem *prob, const struct parameter *param); | |
74 void cross_validation(const struct problem *prob, const struct parameter *param, int nr_fold, int *target); | |
75 | |
76 int predict_values(const struct model *model_, const struct feature_node *x, double* dec_values); | |
77 int predict(const struct model *model_, const struct feature_node *x); | |
78 int predict_probability(const struct model *model_, const struct feature_node *x, double* prob_estimates); | |
79 | |
80 int save_model(const char *model_file_name, const struct model *model_); | |
81 struct model *load_model(const char *model_file_name); | |
82 | |
83 int get_nr_feature(const struct model *model_); | |
84 int get_nr_class(const struct model *model_); | |
85 void get_labels(const struct model *model_, int* label); | |
86 | |
12593
0605cb0434ff
[nan] revert r12777:12778 use liblinear 1.5x - because v1.8 does not support weighted samples
schloegl
parents:
12591
diff
changeset
|
87 void destroy_model(struct model *model_); |
6560 | 88 void destroy_param(struct parameter *param); |
12593
0605cb0434ff
[nan] revert r12777:12778 use liblinear 1.5x - because v1.8 does not support weighted samples
schloegl
parents:
12591
diff
changeset
|
89 const char *check_parameter(const struct parameter *param); |
0605cb0434ff
[nan] revert r12777:12778 use liblinear 1.5x - because v1.8 does not support weighted samples
schloegl
parents:
12591
diff
changeset
|
90 extern void (*liblinear_print_string) (const char *); |
6560 | 91 |
92 #ifdef __cplusplus | |
93 } | |
94 #endif | |
95 | |
96 #endif /* _LIBLINEAR_H */ | |
97 |