comparison toolboxes/SVM-light/src/svm_learn.h @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:e9a9cd732c1e
1 /***********************************************************************/
2 /* */
3 /* svm_learn.h */
4 /* */
5 /* Declarations for learning module of Support Vector Machine. */
6 /* */
7 /* Author: Thorsten Joachims */
8 /* Date: 02.07.02 */
9 /* */
10 /* Copyright (c) 2002 Thorsten Joachims - All rights reserved */
11 /* */
12 /* This software is available for non-commercial use only. It must */
13 /* not be modified and distributed without prior permission of the */
14 /* author. The author is not responsible for implications from the */
15 /* use of this software. */
16 /* */
17 /***********************************************************************/
18
19 #ifndef SVM_LEARN
20 #define SVM_LEARN
21
22 void svm_learn_classification(DOC **, double *, long, long, LEARN_PARM *,
23 KERNEL_PARM *, KERNEL_CACHE *, MODEL *,
24 double *);
25 void svm_learn_regression(DOC **, double *, long, long, LEARN_PARM *,
26 KERNEL_PARM *, KERNEL_CACHE **, MODEL *);
27 void svm_learn_ranking(DOC **, double *, long, long, LEARN_PARM *,
28 KERNEL_PARM *, KERNEL_CACHE **, MODEL *);
29 void svm_learn_optimization(DOC **, double *, long, long, LEARN_PARM *,
30 KERNEL_PARM *, KERNEL_CACHE *, MODEL *,
31 double *);
32 long optimize_to_convergence(DOC **, long *, long, long, LEARN_PARM *,
33 KERNEL_PARM *, KERNEL_CACHE *, SHRINK_STATE *,
34 MODEL *, long *, long *, double *,
35 double *, double *,
36 TIMING *, double *, long, long);
37 long optimize_to_convergence_sharedslack(DOC **, long *, long, long,
38 LEARN_PARM *,
39 KERNEL_PARM *, KERNEL_CACHE *, SHRINK_STATE *,
40 MODEL *, double *, double *, double *,
41 TIMING *, double *);
42 double compute_objective_function(double *, double *, double *, double,
43 long *, long *);
44 void clear_index(long *);
45 void add_to_index(long *, long);
46 long compute_index(long *,long, long *);
47 void optimize_svm(DOC **, long *, long *, long *, double, long *, long *,
48 MODEL *,
49 long, long *, long, double *, double *, double *,
50 LEARN_PARM *, CFLOAT *, KERNEL_PARM *, QP *, double *);
51 void compute_matrices_for_optimization(DOC **, long *, long *, long *, double,
52 long *,
53 long *, long *, MODEL *, double *,
54 double *, double *, long, long, LEARN_PARM *,
55 CFLOAT *, KERNEL_PARM *, QP *);
56 long calculate_svm_model(DOC **, long *, long *, double *, double *,
57 double *, double *, LEARN_PARM *, long *,
58 long *, MODEL *);
59 long check_optimality(MODEL *, long *, long *, double *, double *,
60 double *, long,
61 LEARN_PARM *,double *, double, long *, long *, long *,
62 long *, long, KERNEL_PARM *);
63 long check_optimality_sharedslack(DOC **docs, MODEL *model, long int *label,
64 double *a, double *lin, double *c, double *slack,
65 double *alphaslack, long int totdoc,
66 LEARN_PARM *learn_parm, double *maxdiff,
67 double epsilon_crit_org, long int *misclassified,
68 long int *active2dnum,
69 long int *last_suboptimal_at,
70 long int iteration, KERNEL_PARM *kernel_parm);
71 void compute_shared_slacks(DOC **docs, long int *label, double *a,
72 double *lin, double *c, long int *active2dnum,
73 LEARN_PARM *learn_parm,
74 double *slack, double *alphaslack);
75 long identify_inconsistent(double *, long *, long *, long, LEARN_PARM *,
76 long *, long *);
77 long identify_misclassified(double *, long *, long *, long,
78 MODEL *, long *, long *);
79 long identify_one_misclassified(double *, long *, long *, long,
80 MODEL *, long *, long *);
81 long incorporate_unlabeled_examples(MODEL *, long *,long *, long *,
82 double *, double *, long, double *,
83 long *, long *, long, KERNEL_PARM *,
84 LEARN_PARM *);
85 void update_linear_component(DOC **, long *, long *, double *, double *,
86 long *, long, long, KERNEL_PARM *,
87 KERNEL_CACHE *, double *,
88 CFLOAT *, double *);
89 long select_next_qp_subproblem_grad(long *, long *, double *,
90 double *, double *, long,
91 long, LEARN_PARM *, long *, long *,
92 long *, double *, long *, KERNEL_CACHE *,
93 long, long *, long *);
94 long select_next_qp_subproblem_rand(long *, long *, double *,
95 double *, double *, long,
96 long, LEARN_PARM *, long *, long *,
97 long *, double *, long *, KERNEL_CACHE *,
98 long *, long *, long);
99 long select_next_qp_slackset(DOC **docs, long int *label, double *a,
100 double *lin, double *slack, double *alphaslack,
101 double *c, LEARN_PARM *learn_parm,
102 long int *active2dnum, double *maxviol);
103 void select_top_n(double *, long, long *, long);
104 void init_shrink_state(SHRINK_STATE *, long, long);
105 void shrink_state_cleanup(SHRINK_STATE *);
106 long shrink_problem(DOC **, LEARN_PARM *, SHRINK_STATE *, KERNEL_PARM *,
107 long *, long *, long, long, long, double *, long *);
108 void reactivate_inactive_examples(long *, long *, double *, SHRINK_STATE *,
109 double *, double*, long, long, long, LEARN_PARM *,
110 long *, DOC **, KERNEL_PARM *,
111 KERNEL_CACHE *, MODEL *, CFLOAT *,
112 double *, double *);
113
114 /* cache kernel evalutations to improve speed */
115 KERNEL_CACHE *kernel_cache_init(long, long);
116 void kernel_cache_cleanup(KERNEL_CACHE *);
117 void get_kernel_row(KERNEL_CACHE *,DOC **, long, long, long *, CFLOAT *,
118 KERNEL_PARM *);
119 void cache_kernel_row(KERNEL_CACHE *,DOC **, long, KERNEL_PARM *);
120 void cache_multiple_kernel_rows(KERNEL_CACHE *,DOC **, long *, long,
121 KERNEL_PARM *);
122 void kernel_cache_shrink(KERNEL_CACHE *,long, long, long *);
123 void kernel_cache_reset_lru(KERNEL_CACHE *);
124 long kernel_cache_malloc(KERNEL_CACHE *);
125 void kernel_cache_free(KERNEL_CACHE *,long);
126 long kernel_cache_free_lru(KERNEL_CACHE *);
127 CFLOAT *kernel_cache_clean_and_malloc(KERNEL_CACHE *,long);
128 long kernel_cache_touch(KERNEL_CACHE *,long);
129 long kernel_cache_check(KERNEL_CACHE *,long);
130 long kernel_cache_space_available(KERNEL_CACHE *);
131
132 void compute_xa_estimates(MODEL *, long *, long *, long, DOC **,
133 double *, double *, KERNEL_PARM *,
134 LEARN_PARM *, double *, double *, double *);
135 double xa_estimate_error(MODEL *, long *, long *, long, DOC **,
136 double *, double *, KERNEL_PARM *,
137 LEARN_PARM *);
138 double xa_estimate_recall(MODEL *, long *, long *, long, DOC **,
139 double *, double *, KERNEL_PARM *,
140 LEARN_PARM *);
141 double xa_estimate_precision(MODEL *, long *, long *, long, DOC **,
142 double *, double *, KERNEL_PARM *,
143 LEARN_PARM *);
144 void avg_similarity_of_sv_of_one_class(MODEL *, DOC **, double *, long *, KERNEL_PARM *, double *, double *);
145 double most_similar_sv_of_same_class(MODEL *, DOC **, double *, long, long *, KERNEL_PARM *, LEARN_PARM *);
146 double distribute_alpha_t_greedily(long *, long, DOC **, double *, long, long *, KERNEL_PARM *, LEARN_PARM *, double);
147 double distribute_alpha_t_greedily_noindex(MODEL *, DOC **, double *, long, long *, KERNEL_PARM *, LEARN_PARM *, double);
148 void estimate_transduction_quality(MODEL *, long *, long *, long, DOC **, double *);
149 double estimate_margin_vcdim(MODEL *, double, double, KERNEL_PARM *);
150 double estimate_sphere(MODEL *, KERNEL_PARM *);
151 double estimate_r_delta_average(DOC **, long, KERNEL_PARM *);
152 double estimate_r_delta(DOC **, long, KERNEL_PARM *);
153 double length_of_longest_document_vector(DOC **, long, KERNEL_PARM *);
154
155 void write_model(char *, MODEL *);
156 void write_prediction(char *, MODEL *, double *, double *, long *, long *,
157 long, LEARN_PARM *);
158 void write_alphas(char *, double *, long *, long);
159
160 typedef struct cache_parm_s {
161 KERNEL_CACHE *kernel_cache;
162 CFLOAT *cache;
163 DOC **docs;
164 long m;
165 KERNEL_PARM *kernel_parm;
166 long offset,stepsize;
167 } cache_parm_t;
168
169 #endif