Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
This module provides a safe bindings to libsvm functions and structures with implicit memory handling.
Synopsis
- type Vector = IntMap Double
- type Problem = [(Double, Vector)]
- data KernelType
- data Algorithm
- data ExtraParam = ExtraParam {}
- data Model
- train :: Algorithm -> KernelType -> Problem -> IO Model
- train' :: ExtraParam -> Algorithm -> KernelType -> Problem -> IO Model
- crossValidate :: Algorithm -> KernelType -> Problem -> Int -> IO [Double]
- crossValidate' :: ExtraParam -> Algorithm -> KernelType -> Problem -> Int -> IO [Double]
- loadModel :: FilePath -> IO Model
- saveModel :: Model -> FilePath -> IO ()
- predict :: Model -> Vector -> IO Double
- withPrintFn :: CSvmPrintFn -> IO a -> IO a
- type CSvmPrintFn = CString -> IO ()
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.
SVM Algorithm with parameters
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
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
type CSvmPrintFn = CString -> IO () Source #