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