This is an “FFI”-based interface to LibSVM.
The package “LIBSVM” is :CASE-SENSITIVE
,
and you do not need the svm_
prefix.
When this module is present, *FEATURES*
contains the symbol :LIBSVM
.
See modules/libsvm/test.tst
for sample usage.
All data is kept on the C side as much as possible, so these foreign types do not have a CLOS counterpart.
LIST
on the lisp side.LIST
on the lisp side.VECTOR
on the lisp side.FFI:FOREIGN-POINTER
.(problem-l problem
)
problem
(a
FFI:FOREIGN-VARIABLE
)(problem-y problem
&OPTIONAL
(length
(problem-l problem
)))
(VECTOR
DOUBLE-FLOAT
length
)
representing the targets in the
problem
(a FFI:FOREIGN-VARIABLE
).(problem-y-n problem
n
&OPTIONAL
(length
(problem-l problem
))))
DOUBLE-FLOAT
representing the n
th
target in the problem
(a FFI:FOREIGN-VARIABLE
).
(problem-x problem
&OPTIONAL
(length
(problem-l problem
)))
(VECTOR
(VECTOR
node) length
)
representing the predictors in the problem
(a FFI:FOREIGN-VARIABLE
).(problem-x-n problem
n
&OPTIONAL
(length
(problem-l problem
))))
(VECTOR
node)
representing the n
th set of predictors in the problem
(a
FFI:FOREIGN-VARIABLE
).(make-problem &KEY
l
y
x
)
FFI:FOREIGN-VARIABLE
representing
a model.(destroy-problem problem
)
Release the memory taken by the problem
object and invalidate the FFI:FOREIGN-VARIABLE
problem
.
You must call this function yourself, but only
after deallocating all model objects trained from
this problem
.
(load-problem filename
&KEY
(log
*STANDARD-OUTPUT*
))
Read a problem from a file in the libsvm/svmlight format. Return two values: the problem and max index (i.e., the number of columns).
Messages go to log
.
(save-problem filename
problem
&KEY
(log
*STANDARD-OUTPUT*
))
Write a problem into a file.
Messages go to log
.
(destroy-model model
)
Release the memory taken by the model
object and invalidate the FFI:FOREIGN-VARIABLE
model
.
Calls svm_destroy_model
.
You do not have to call this function yourself, it is
attached to the model
by train
and load-model
via EXT:FINALIZE
.
(check-parameter problem
parameter
)
Check if the parameter
is appropriate for the
problem
.
Calls svm_check_parameter
.
(train problem
parameter
)
Train a model.
Calls svm_train
and check-parameter
.
(cross-validation problem
parameter
n
)
Run n
-fold cross-validation.
Calls svm_cross_validation
and check-parameter
.
(save-model filename
model
)
Write a model into a file.
Calls svm_save_model
.
(load-model filename
)
Read a model from a file.
Calls svm_load_model
.
(get-svm-type model
)
svm_get_svm_type
.
(get-nr-class model
)
svm_get_nr_class
.
(get-labels model
)
svm_get_labels
.
(get-svr-probability model
)
svm_get_svr_probability
.
(predict-values model
x
)
Return the decision values
(a (
) given
by VECTOR
DOUBLE-FLOAT
)model
for x
(a (
).
VECTOR
node)
Calls svm_predict_values
.
(predict model
x
)
svm_predict
.
(predict-probability model
x
)
svm_predict_probability
.
(check-probability-model model
)
svm_check_probability_model
.
(destroy-parameter parameter
)
Release the memory taken by the parameter
object and invalidate the FFI:FOREIGN-VARIABLE
parameter
.
Does not call svm_destroy_param
.
You do not have to call this function yourself, it is
attached to the parameter
by make-parameter
via EXT:FINALIZE
.
(make-parameter &KEY
:v svm_type
kernel_type degree gamma coef0 cache_size eps C nr_weight
weight_label weight nu p shrinking probability)
Allocates a new FFI:FOREIGN-VARIABLE
of
type parameter with the supplied slots.
The defaults come from vector v
(such as returned
by (
), if supplied, providing
an easy way to copy FFI:FOREIGN-VALUE
parameter
)parameter
s, otherwise the defaults
for svm-train are used.
(parameter-alist parameter
)
parameter
.
These notes document CLISP version 2.49 | Last modified: 2010-07-07 |