libsvm

LIBSVM bindings for OCaml
IN THIS PACKAGE
Module Libsvm . Svm . Problem
type t

Type of a SVM problem (training set).

val create : x:(int * float) list array -> y:Lacaml.D.vec -> t

create ~x ~y constructs a problem from a sparse encoding x of training vectors and a target vector y.

val create_dense : x:Lacaml.D.mat -> y:Lacaml.D.vec -> t

create_dense ~x ~y constructs a problem from a dense encoding x of training vectors and a target vector y. This is useful in particular in conjunction with the `PRECOMPUTED type of kernel when invoking train. In that case x represents a kernel matrix of the following form:

1 K(x1,x1) K(x1,x2) ... K(x1,xL)

2 K(x2,x1) K(x2,x2) ... K(x2,xL)

...

L K(xL,x1) K(xL,x2) ... K(xL,xL)

where L denotes the number of training instances and K(x,y) is the precomputed kernel value of the two training instances x and y.

val get_n_samples : t -> int

get_n_samples prob

  • returns

    the number of training samples.

val get_n_feats : t -> int

get_n_feats prob

  • returns

    the number of features (attributes).

val get_targets : t -> Lacaml.D.vec

get_targets prob

  • returns

    the targets of training instances.

val load : string -> t

load filename loads a problem from the file filename.

  • raises Failure

    if an error occured during parsing of filename.

val output : t -> out_channel -> unit

output prob oc outputs the problem prob to an output channel oc. NOTE: the function does not close the output channel.

val save : t -> string -> unit

save prob filename saves the problem prob to the file filename.

val min_max_feats : t -> [ `Min of Lacaml.D.vec ] * [ `Max of Lacaml.D.vec ]

min_max_feats prob

  • returns

    the smallest and largest feature value for each column in the feature matrix.

val scale : ?lower:float -> ?upper:float -> t -> unit

scale ?lower ?upper prob scales in place prob such that each feature (attribute) lies in the range [lower,upper]. The default range is [-1,1].

val print : t -> unit

print prob prints the internal representation of a problem. It is mainly used for debugging purposes.