Hugin trunk 0.1
Loading...
Searching...
No Matches
svm.h
Go to the documentation of this file.
1/*
2Copyright (c) 2000-2014 Chih-Chung Chang and Chih-Jen Lin
3All rights reserved.
4
5Redistribution and use in source and binary forms, with or without
6modification, are permitted provided that the following conditions
7are met:
8
91. Redistributions of source code must retain the above copyright
10notice, this list of conditions and the following disclaimer.
11
122. Redistributions in binary form must reproduce the above copyright
13notice, this list of conditions and the following disclaimer in the
14documentation and/or other materials provided with the distribution.
15
163. Neither name of copyright holders nor the names of its contributors
17may be used to endorse or promote products derived from this software
18without specific prior written permission.
19
20
21THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
25CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
33*/
34#ifndef _LIBSVM_H
35#define _LIBSVM_H
36
37#define LIBSVM_VERSION 320
38
39namespace celeste
40{
41
42extern int libsvm_version;
43
45{
46 int index;
47 double value;
48};
49
51{
52 int l;
53 double *y;
54 struct svm_node **x;
55};
56
57enum { C_SVC, NU_SVC, ONE_CLASS, EPSILON_SVR, NU_SVR }; /* svm_type */
58enum { LINEAR, POLY, RBF, SIGMOID, PRECOMPUTED }; /* kernel_type */
59
61{
64 int degree; /* for poly */
65 double gamma; /* for poly/rbf/sigmoid */
66 double coef0; /* for poly/sigmoid */
67
68 /* these are for training only */
69 double cache_size; /* in MB */
70 double eps; /* stopping criteria */
71 double C; /* for C_SVC, EPSILON_SVR and NU_SVR */
72 int nr_weight; /* for C_SVC */
73 int *weight_label; /* for C_SVC */
74 double* weight; /* for C_SVC */
75 double nu; /* for NU_SVC, ONE_CLASS, and NU_SVR */
76 double p; /* for EPSILON_SVR */
77 int shrinking; /* use the shrinking heuristics */
78 int probability; /* do probability estimates */
79};
80
81//
82// svm_model
83//
85{
86 struct svm_parameter param; /* parameter */
87 int nr_class; /* number of classes, = 2 in regression/one class svm */
88 int l; /* total #SV */
89 struct svm_node **SV; /* SVs (SV[l]) */
90 double **sv_coef; /* coefficients for SVs in decision functions (sv_coef[k-1][l]) */
91 double *rho; /* constants in decision functions (rho[k*(k-1)/2]) */
92 double *probA; /* pariwise probability information */
93 double *probB;
94 int *sv_indices; /* sv_indices[0,...,nSV-1] are values in [1,...,num_traning_data] to indicate SVs in the training set */
95
96 /* for classification only */
97
98 int *label; /* label of each class (label[k]) */
99 int *nSV; /* number of SVs for each class (nSV[k]) */
100 /* nSV[0] + nSV[1] + ... + nSV[k-1] = l */
101 /* XXX */
102 int free_sv; /* 1 if svm_model is created by svm_load_model*/
103 /* 0 if svm_model is created by svm_train */
104};
105
106struct svm_model *svm_train(const struct svm_problem *prob, const struct svm_parameter *param);
107void svm_cross_validation(const struct svm_problem *prob, const struct svm_parameter *param, int nr_fold, double *target);
108
109int svm_save_model(const char *model_file_name, const struct svm_model *model);
110struct svm_model *svm_load_model(const char *model_file_name);
111
114void svm_get_labels(const struct svm_model *model, int *label);
115void svm_get_sv_indices(const struct svm_model *model, int *sv_indices);
116int svm_get_nr_sv(const struct svm_model *model);
118
119double svm_predict_values(const struct svm_model *model, const struct svm_node *x, double* dec_values);
120double svm_predict(const struct svm_model *model, const struct svm_node *x);
121double svm_predict_probability(const struct svm_model *model, const struct svm_node *x, double* prob_estimates);
122
125void svm_destroy_param(struct svm_parameter *param);
126
127const char *svm_check_parameter(const struct svm_problem *prob, const struct svm_parameter *param);
129
130void svm_set_print_string_function(void (*print_func)(const char *));
131
132}; //namespace
133#endif /* _LIBSVM_H */
int libsvm_version
Definition svm.cpp:58
svm_model * svm_load_model(const char *model_file_name)
Definition svm.cpp:2933
void svm_destroy_param(svm_parameter *param)
Definition svm.cpp:3083
const char * svm_check_parameter(const svm_problem *prob, const svm_parameter *param)
Definition svm.cpp:3089
int svm_get_svm_type(const svm_model *model)
Definition svm.cpp:2509
void svm_get_labels(const svm_model *model, int *label)
Definition svm.cpp:2519
int svm_save_model(const char *model_file_name, const svm_model *model)
Definition svm.cpp:2690
@ LINEAR
Definition svm.h:58
@ SIGMOID
Definition svm.h:58
@ PRECOMPUTED
Definition svm.h:58
@ RBF
Definition svm.h:58
@ POLY
Definition svm.h:58
void svm_set_print_string_function(void(*print_func)(const char *))
Definition svm.cpp:3218
void svm_free_and_destroy_model(svm_model **model_ptr_ptr)
Definition svm.cpp:3073
svm_model * svm_train(const svm_problem *prob, const svm_parameter *param)
Definition svm.cpp:2141
int svm_get_nr_sv(const svm_model *model)
Definition svm.cpp:2533
int svm_check_probability_model(const svm_model *model)
Definition svm.cpp:3210
double svm_predict_values(const svm_model *model, const svm_node *x, double *dec_values)
Definition svm.cpp:2550
double svm_predict_probability(const svm_model *model, const svm_node *x, double *prob_estimates)
Definition svm.cpp:2641
void svm_cross_validation(const svm_problem *prob, const svm_parameter *param, int nr_fold, double *target)
Definition svm.cpp:2388
double svm_predict(const svm_model *model, const svm_node *x)
Definition svm.cpp:2626
double svm_get_svr_probability(const svm_model *model)
Definition svm.cpp:2538
void svm_get_sv_indices(const svm_model *model, int *indices)
Definition svm.cpp:2526
int svm_get_nr_class(const svm_model *model)
Definition svm.cpp:2514
void svm_free_model_content(svm_model *model_ptr)
Definition svm.cpp:3038
@ NU_SVR
Definition svm.h:57
@ EPSILON_SVR
Definition svm.h:57
@ C_SVC
Definition svm.h:57
@ ONE_CLASS
Definition svm.h:57
@ NU_SVC
Definition svm.h:57
struct svm_parameter param
Definition svm.h:86
double * probB
Definition svm.h:93
double ** sv_coef
Definition svm.h:90
double * rho
Definition svm.h:91
double * probA
Definition svm.h:92
int * label
Definition svm.h:98
struct svm_node ** SV
Definition svm.h:89
int * sv_indices
Definition svm.h:94
double value
Definition svm.h:47
double cache_size
Definition svm.h:69
double * weight
Definition svm.h:74
double * y
Definition svm.h:53
struct svm_node ** x
Definition svm.h:54
std::vector< deghosting::BImagePtr > threshold(const std::vector< deghosting::FImagePtr > &inputImages, const double threshold, const uint16_t flags)
Threshold function used for creating alpha masks for images.
Definition threshold.h:41