source: orange/source/orange/liblinear/linear.h @ 8978:f0ba3673b0a7

Revision 8978:f0ba3673b0a7, 1.9 KB checked in by ales_erjavec <ales.erjavec@…>, 3 years ago (diff)

Refactored the code for LibSVM and LIBLINEAR. The sources are unmodified in liblinear and libsvm directories. Can be excluded from the build and instead linked to a system libraries instead.
The most significant change is in the way custom kernels are handled for SVMLearner - it now uses 'PRECOMPUTED' kernel functionality from LibSVM (as a bonus the results seem to be better then before (was there a bug in the previous code?), also faster)

Line 
1#ifndef _LIBLINEAR_H
2#define _LIBLINEAR_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8struct feature_node
9{
10    int index;
11    double value;
12};
13
14struct problem
15{
16    int l, n;
17    int *y;
18    struct feature_node **x;
19    double bias;            /* < 0 if no bias term */ 
20};
21
22enum { 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
24struct 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
36struct 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
46struct model* train(const struct problem *prob, const struct parameter *param);
47void cross_validation(const struct problem *prob, const struct parameter *param, int nr_fold, int *target);
48
49int predict_values(const struct model *model_, const struct feature_node *x, double* dec_values);
50int predict(const struct model *model_, const struct feature_node *x);
51int predict_probability(const struct model *model_, const struct feature_node *x, double* prob_estimates);
52
53int save_model(const char *model_file_name, const struct model *model_);
54struct model *load_model(const char *model_file_name);
55
56int get_nr_feature(const struct model *model_);
57int get_nr_class(const struct model *model_);
58void get_labels(const struct model *model_, int* label);
59
60void free_model_content(struct model *model_ptr);
61void free_and_destroy_model(struct model **model_ptr_ptr);
62void destroy_param(struct parameter *param);
63
64const char *check_parameter(const struct problem *prob, const struct parameter *param);
65int check_probability_model(const struct model *model);
66void set_print_string_function(void (*print_func) (const char*));
67
68#ifdef __cplusplus
69}
70#endif
71
72#endif /* _LIBLINEAR_H */
73
Note: See TracBrowser for help on using the repository browser.