1#![allow(non_snake_case)]
3
4use std::os::raw::c_int;
5
6pub const LIBSVM_VERSION: u32 = 324;
7extern "C" {
8 pub static mut libsvm_version: c_int;
9}
10
11#[repr(C)]
12#[derive(Debug, Copy, Clone)]
13pub struct svm_node {
14 pub index: c_int,
15 pub value: f64,
16}
17
18#[repr(C)]
19#[derive(Debug, Copy, Clone)]
20pub struct svm_problem {
21 pub l: c_int,
22 pub y: *mut f64,
23 pub x: *mut *mut svm_node,
24}
25
26pub const C_SVC: u32 = 0;
27pub const NU_SVC: u32 = 1;
28pub const ONE_CLASS: u32 = 2;
29pub const EPSILON_SVR: u32 = 3;
30pub const NU_SVR: u32 = 4;
31pub const LINEAR: u32 = 0;
32pub const POLY: u32 = 1;
33pub const RBF: u32 = 2;
34pub const SIGMOID: u32 = 3;
35pub const PRECOMPUTED: u32 = 4;
36
37#[repr(C)]
38#[derive(Debug, Copy, Clone)]
39pub struct svm_parameter {
40 pub svm_type: c_int,
41 pub kernel_type: c_int,
42 pub degree: c_int,
43 pub gamma: f64,
44 pub coef0: f64,
45 pub cache_size: f64,
46 pub eps: f64,
47 pub C: f64,
48 pub nr_weight: c_int,
49 pub weight_label: *mut c_int,
50 pub weight: *mut f64,
51 pub nu: f64,
52 pub p: f64,
53 pub shrinking: c_int,
54 pub probability: c_int,
55}
56
57#[repr(C)]
58#[derive(Debug, Copy, Clone)]
59pub struct svm_model {
60 pub param: svm_parameter,
61 pub nr_class: c_int,
62 pub l: c_int,
63 pub SV: *mut *mut svm_node,
64 pub sv_coef: *mut *mut f64,
65 pub rho: *mut f64,
66 pub probA: *mut f64,
67 pub probB: *mut f64,
68 pub sv_indices: *mut c_int,
69 pub label: *mut c_int,
70 pub nSV: *mut c_int,
71 pub free_sv: c_int,
72}
73
74extern "C" {
75 pub fn svm_train(prob: *const svm_problem, param: *const svm_parameter) -> *mut svm_model;
76
77 pub fn svm_cross_validation(
78 prob: *const svm_problem,
79 param: *const svm_parameter,
80 nr_fold: c_int,
81 target: *mut f64,
82 );
83
84 pub fn svm_save_model(
85 model_file_name: *const ::std::os::raw::c_char,
86 model: *const svm_model,
87 ) -> c_int;
88
89 pub fn svm_load_model(model_file_name: *const ::std::os::raw::c_char) -> *mut svm_model;
90
91 pub fn svm_get_svm_type(model: *const svm_model) -> c_int;
92
93 pub fn svm_get_nr_class(model: *const svm_model) -> c_int;
94
95 pub fn svm_get_labels(model: *const svm_model, label: *mut c_int);
96
97 pub fn svm_get_sv_indices(model: *const svm_model, sv_indices: *mut c_int);
98
99 pub fn svm_get_nr_sv(model: *const svm_model) -> c_int;
100
101 pub fn svm_get_svr_probability(model: *const svm_model) -> f64;
102
103 pub fn svm_predict_values(
104 model: *const svm_model,
105 x: *const svm_node,
106 dec_values: *mut f64,
107 ) -> f64;
108
109 pub fn svm_predict(model: *const svm_model, x: *const svm_node) -> f64;
110
111 pub fn svm_predict_probability(
112 model: *const svm_model,
113 x: *const svm_node,
114 prob_estimates: *mut f64,
115 ) -> f64;
116
117 pub fn svm_free_model_content(model_ptr: *mut svm_model);
118
119 pub fn svm_free_and_destroy_model(model_ptr_ptr: *mut *mut svm_model);
120
121 pub fn svm_destroy_param(param: *mut svm_parameter);
122
123 pub fn svm_check_parameter(
124 prob: *const svm_problem,
125 param: *const svm_parameter,
126 ) -> *const ::std::os::raw::c_char;
127
128 pub fn svm_check_probability_model(model: *const svm_model) -> c_int;
129
130 pub fn svm_set_print_string_function(
131 print_func: ::std::option::Option<
132 unsafe extern "C" fn(arg1: *const ::std::os::raw::c_char),
133 >,
134 );
135}