-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsvm.h
More file actions
48 lines (40 loc) · 1.7 KB
/
Copy pathsvm.h
File metadata and controls
48 lines (40 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#ifndef LIBVM_SVM_H_
#define LIBVM_SVM_H_
#include "utilities.h"
#include "kernel.h"
enum { C_SVC, NU_SVC, OVA_SVC }; // svm_type
struct SVMParameter {
struct KernelParameter *kernel_param;
int svm_type;
double cache_size; // in MB
double eps; // stopping criteria
double C; // for C_SVC and OVA_SVC
int num_weights; // for C_SVC and OVA_SVC
int *weight_labels; // for C_SVC and OVA_SVC
double *weights; // for C_SVC and OVA_SVC
double nu; // for NU_SVC
int shrinking; // use the shrinking heuristics
};
struct SVMModel {
struct SVMParameter param;
int num_ex;
int num_classes; // number of classes (k)
int total_sv; // total #SV
struct Node **svs; // SVs (SV[total_sv])
double **sv_coef; // coefficients for SVs in decision functions
double *rho; // constants in decision functions
int *sv_indices; // sv_indices[0,...,nSV-1] are values in [1,...,num_traning_data] to indicate SVs in the training set
int *labels; // label of each class (label[k])
int *num_svs; // number of SVs for each class (nSV[k])
// nSV[0] + nSV[1] + ... + nSV[k-1] = total_sv
};
SVMModel *TrainSVM(const struct Problem *prob, const struct SVMParameter *param);
double PredictSVMValues(const struct SVMModel *model, const struct Node *x, double *decision_values);
double PredictSVM(const struct SVMModel *model, const struct Node *x);
int SaveSVMModel(std::ofstream &model_file, const struct SVMModel *model);
SVMModel *LoadSVMModel(std::ifstream &model_file);
void FreeSVMModel(struct SVMModel *model);
void FreeSVMParam(struct SVMParameter *param);
void InitSVMParam(struct SVMParameter *param);
const char *CheckSVMParameter(const struct SVMParameter *param);
#endif // LIBVM_SVM_H_