33.10. LibSVM Interface
Prev Chapter 33. Extensions Implemented as Modules Next

33.10. LibSVM Interface

33.10.1. Types
33.10.2. Functions
33.10.2.1. Functions related to problem
33.10.2.2. Functions related to model
33.10.2.3. Functions related to parameter

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.

33.10.1. Types

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.

33.10.2. Functions

33.10.2.1. Functions related to problem
33.10.2.2. Functions related to model
33.10.2.3. Functions related to parameter

33.10.2.1. Functions related to problem

(problem-l problem)
Return the number of rows in the problem (a FFI:FOREIGN-VARIABLE)
(problem-y problem &OPTIONAL (length (problem-l problem)))
Return a (VECTOR DOUBLE-FLOAT length) representing the targets in the problem (a FFI:FOREIGN-VARIABLE).
(problem-y-n problem n &OPTIONAL (length (problem-l problem))))
Return the DOUBLE-FLOAT representing the nth target in the problem (a FFI:FOREIGN-VARIABLE).
(problem-x problem &OPTIONAL (length (problem-l problem)))
Return a (VECTOR (VECTOR node) length) representing the predictors in the problem (a FFI:FOREIGN-VARIABLE).
(problem-x-n problem n &OPTIONAL (length (problem-l problem))))
Return the (VECTOR node) representing the nth set of predictors in the problem (a 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.

33.10.2.2. Functions related to model

(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)
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 (VECTOR DOUBLE-FLOAT)) given by model for x (a (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.

33.10.2.3. Functions related to parameter

(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 (FFI:FOREIGN-VALUE parameter)), if supplied, providing an easy way to copy parameters, otherwise the defaults for svm-train are used.

(parameter-alist parameter)
Return the association list representing parameter.

These notes document CLISP version 2.49Last modified: 2010年07月07日




33.9. Oracle Interface Home 33.11. Computer Algebra System PARI

AltStyle によって変換されたページ (->オリジナル) /