HSvm-0.1.1.3.25: Haskell Bindings for libsvm
Safe HaskellNone
LanguageHaskell2010

Data.SVM

Description

This module provides a safe bindings to libsvm functions and structures with implicit memory handling.

Synopsis

Documentation

type Vector = IntMap Double Source #

Vector type provides a sparse implementation of vector. It uses IntMap as underlying implementation.

type Problem = [(Double, Vector)] Source #

SVM problem is a list of maps from training vectors to 1.0 or -1.0

data KernelType Source #

Kernel function for SVM algorithm.

Constructors

Linear

Linear kernel function, i.e. dot product

RBF

Gaussian radial basis function with parameter gamma

Fields

Sigmoid

Sigmoid kernel function

Fields

Poly

Inhomogeneous polynomial function

Fields

data Algorithm Source #

SVM Algorithm with parameters

Constructors

CSvc

c-SVC algorithm

Fields

NuSvc

nu-SVC algorithm

Fields

NuSvr

nu-SVR algorithm

Fields

EpsilonSvr

eps-SVR algorithm

Fields

OneClassSvm

One class SVM

Fields

data ExtraParam Source #

Extra parameters of SVM implementation

Constructors

ExtraParam 

data Model Source #

Model is a wrapper over foreign pointer to CSvmModel

train :: Algorithm -> KernelType -> Problem -> IO Model Source #

The train function allows training a Model starting from a Problem by specifying an Algorithm and a KernelType

train' :: ExtraParam -> Algorithm -> KernelType -> Problem -> IO Model Source #

Like train but with extra parameters

crossValidate :: Algorithm -> KernelType -> Problem -> Int -> IO [Double] Source #

Stratified cross validation

crossValidate' :: ExtraParam -> Algorithm -> KernelType -> Problem -> Int -> IO [Double] Source #

Like crossvalidate but with extra parameters

loadModel :: FilePath -> IO Model Source #

Load model from the file

saveModel :: Model -> FilePath -> IO () Source #

Save model to the file

predict :: Model -> Vector -> IO Double Source #

Predict a value for Vector by using Model

withPrintFn :: CSvmPrintFn -> IO a -> IO a Source #

Wrapper to change the libsvm output reporting function.

libsvm by default writes some statistics to stdout. If you don't want any output from libsvm, you can do e.g.:

>>> withPrintFn (\_ -> return ()) $ train (NuSvc 0.25) (RBF 1) feats