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.

- node
- Corresponds to svm_node, represented
as a
`LIST`

on the lisp side. - problem
- Corresponds to svm_problem, represented
as a
`LIST`

on the lisp side. - parameter
- Corresponds to svm_parameter, represented
as a
`VECTOR`

on the lisp side. - model
- Corresponds to svm_model, an opaque
`FFI:FOREIGN-POINTER`

.

`(problem-l`

)`problem`

- Return the number of rows in the
(a`problem`

`FFI:FOREIGN-VARIABLE`

) `(problem-y`

`problem`

`&OPTIONAL`

((problem-l`length`

)))`problem`

- Return a
`(`

representing the targets in the`VECTOR`

`DOUBLE-FLOAT`

)`length`

(a`problem`

`FFI:FOREIGN-VARIABLE`

). `(problem-y-n`

`problem`

`n`

`&OPTIONAL`

((problem-l`length`

))))`problem`

- Return the
`DOUBLE-FLOAT`

representing theth target in the`n`

(a`problem`

`FFI:FOREIGN-VARIABLE`

). `(problem-x`

`problem`

`&OPTIONAL`

((problem-l`length`

)))`problem`

- Return a
`(`

representing the predictors in the`VECTOR`

(`VECTOR`

node))`length`

(a`problem`

`FFI:FOREIGN-VARIABLE`

). `(problem-x-n`

`problem`

`n`

`&OPTIONAL`

((problem-l`length`

))))`problem`

- Return the
`(`

representing the`VECTOR`

node)th set of predictors in the`n`

(a`problem`

`FFI:FOREIGN-VARIABLE`

). `(make-problem`

`&KEY`

`l`

`y`

)`x`

- Allocate a
`FFI:FOREIGN-VARIABLE`

representing a model. `(destroy-problem`

)`problem`

Release the memory taken by the problem object and invalidate the

`FFI:FOREIGN-VARIABLE`

.`problem`

### Warning

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 theby`model`

`train`

and`load-model`

via`EXT:FINALIZE`

.`(check-parameter`

`problem`

)`parameter`

Check if the

is appropriate for the`parameter`

.`problem`

Calls

`svm_check_parameter`

.`(train`

`problem`

)`parameter`

Train a model.

Calls

`svm_train`

and`check-parameter`

.`(cross-validation`

`problem`

`parameter`

)`n`

Run

-fold cross-validation.`n`

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`

- Call
`svm_get_svm_type`

. `(get-nr-class`

)`model`

- Call
`svm_get_nr_class`

. `(get-labels`

)`model`

- Call
`svm_get_labels`

. `(get-svr-probability`

)`model`

- Call
`svm_get_svr_probability`

. `(predict-values`

`model`

)`x`

Return the decision values (a

`(`

) given by`VECTOR`

`DOUBLE-FLOAT`

)for`model`

(a`x`

`(`

).`VECTOR`

node)Calls

`svm_predict_values`

.`(predict`

`model`

)`x`

- Call
`svm_predict`

. `(predict-probability`

`model`

)`x`

- Call
`svm_predict_probability`

. `(check-probability-model`

)`model`

- Call
`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 theby`parameter`

`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

(such as returned by`v`

`(`

), if supplied, providing an easy way to copy`FFI:FOREIGN-VALUE`

)`parameter`

s, otherwise the defaults for`parameter`

**svm-train**are used.`(parameter-alist`

)`parameter`

- Return the association list representing
.`parameter`

These notes document CLISP version 2.49 | Last modified: 2010-07-07 |