-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Haskell Bindings for libsvm -- -- The library embeds libsvm and provides a type-safe interface into SVM -- models. @package HSvm @version 1.0.3.35 -- | This is a module with raw bindings to libsvm module Data.SVM.Raw data CSvmNode CSvmNode :: CInt -> CDouble -> CSvmNode [index] :: CSvmNode -> CInt [value] :: CSvmNode -> CDouble data CSvmProblem CSvmProblem :: CInt -> Ptr CDouble -> Ptr (Ptr CSvmNode) -> CSvmProblem [l] :: CSvmProblem -> CInt [y] :: CSvmProblem -> Ptr CDouble [x] :: CSvmProblem -> Ptr (Ptr CSvmNode) newtype CSvmType CSvmType :: CInt -> CSvmType [unCSvmType] :: CSvmType -> CInt cSvc :: CSvmType nuSvc :: CSvmType newtype CKernelType CKernelType :: CInt -> CKernelType [unCKernelType] :: CKernelType -> CInt oneClass :: CSvmType linear :: CKernelType poly :: CKernelType epsilonSvr :: CSvmType data CSvmParameter CSvmParameter :: CSvmType -> CKernelType -> CInt -> CDouble -> CDouble -> CDouble -> CDouble -> CDouble -> CInt -> Ptr CInt -> Ptr CDouble -> CDouble -> CDouble -> CInt -> CInt -> CSvmParameter [svm_type] :: CSvmParameter -> CSvmType [kernel_type] :: CSvmParameter -> CKernelType [degree] :: CSvmParameter -> CInt [gamma] :: CSvmParameter -> CDouble [coef0] :: CSvmParameter -> CDouble [cache_size] :: CSvmParameter -> CDouble [eps] :: CSvmParameter -> CDouble [c] :: CSvmParameter -> CDouble [nr_weight] :: CSvmParameter -> CInt [weight_label] :: CSvmParameter -> Ptr CInt [weight] :: CSvmParameter -> Ptr CDouble [nu] :: CSvmParameter -> CDouble [p] :: CSvmParameter -> CDouble [shrinking] :: CSvmParameter -> CInt [probability] :: CSvmParameter -> CInt nuSvr :: CSvmType rbf :: CKernelType sigmoid :: CKernelType precomputed :: CKernelType defaultCParam :: CSvmParameter -- | Managed type for struct svm_model. data CSvmModel c_svm_train :: Ptr CSvmProblem -> Ptr CSvmParameter -> IO (Ptr CSvmModel) c_svm_cross_validation :: Ptr CSvmProblem -> Ptr CSvmParameter -> CInt -> Ptr CDouble -> IO () c_svm_predict :: Ptr CSvmModel -> Ptr CSvmNode -> IO CDouble c_svm_save_model :: CString -> Ptr CSvmModel -> IO CInt c_svm_load_model :: CString -> IO (Ptr CSvmModel) c_svm_check_parameter :: Ptr CSvmProblem -> Ptr CSvmParameter -> CString c_svm_destroy_model :: FinalizerPtr CSvmModel c_clone_model_support_vectors :: Ptr CSvmModel -> IO CInt type CSvmPrintFn = CString -> IO () c_svm_set_print_string_function :: FunPtr CSvmPrintFn -> IO () createSvmPrintFnPtr :: CSvmPrintFn -> IO (FunPtr CSvmPrintFn) instance GHC.Show.Show Data.SVM.Raw.CSvmType instance Foreign.Storable.Storable Data.SVM.Raw.CSvmType instance GHC.Show.Show Data.SVM.Raw.CKernelType instance Foreign.Storable.Storable Data.SVM.Raw.CKernelType instance GHC.Show.Show Data.SVM.Raw.CSvmParameter instance Foreign.Storable.Storable Data.SVM.Raw.CSvmParameter instance Foreign.Storable.Storable Data.SVM.Raw.CSvmProblem instance Foreign.Storable.Storable Data.SVM.Raw.CSvmNode -- | This module provides a safe bindings to libsvm functions and -- structures with implicit memory handling. module Data.SVM -- | Vector type provides a sparse implementation of vector. It uses IntMap -- as underlying implementation. type Vector = IntMap Double -- | SVM problem is a list of maps from training vectors to 1.0 or -1.0 type Problem = [(Double, Vector)] -- | Kernel function for SVM algorithm. data KernelType -- | Linear kernel function, i.e. dot product Linear :: KernelType -- | Gaussian radial basis function with parameter gamma RBF :: Double -> KernelType [gamma] :: KernelType -> Double -- | Sigmoid kernel function Sigmoid :: Double -> Double -> KernelType [gamma] :: KernelType -> Double [coef0] :: KernelType -> Double -- | Inhomogeneous polynomial function Poly :: Double -> Double -> Int -> KernelType [gamma] :: KernelType -> Double [coef0] :: KernelType -> Double [degree] :: KernelType -> Int -- | SVM Algorithm with parameters data Algorithm -- | c-SVC algorithm CSvc :: Double -> Algorithm [c] :: Algorithm -> Double -- | nu-SVC algorithm NuSvc :: Double -> Algorithm [nu] :: Algorithm -> Double -- | nu-SVR algorithm NuSvr :: Double -> Double -> Algorithm [nu] :: Algorithm -> Double [c] :: Algorithm -> Double -- | eps-SVR algorithm EpsilonSvr :: Double -> Double -> Algorithm [epsilon] :: Algorithm -> Double [c] :: Algorithm -> Double -- | One class SVM OneClassSvm :: Double -> Algorithm [nu] :: Algorithm -> Double -- | Extra parameters of SVM implementation data ExtraParam ExtraParam :: Double -> Int -> Int -> ExtraParam [cacheSize] :: ExtraParam -> Double [shrinking] :: ExtraParam -> Int [probability] :: ExtraParam -> Int -- | Model is a wrapper over foreign pointer to CSvmModel data Model -- | The train function allows training a Model starting from -- a Problem by specifying an Algorithm and a -- KernelType train :: Algorithm -> KernelType -> Problem -> IO Model -- | Like train but with extra parameters train' :: ExtraParam -> Algorithm -> KernelType -> Problem -> IO Model -- | Stratified cross validation crossValidate :: Algorithm -> KernelType -> Problem -> Int -> IO [Double] -- | Like crossvalidate but with extra parameters crossValidate' :: ExtraParam -> Algorithm -> KernelType -> Problem -> Int -> IO [Double] -- | Load model from the file loadModel :: FilePath -> IO Model -- | Save model to the file saveModel :: Model -> FilePath -> IO () -- | Predict a value for Vector by using Model predict :: Model -> Vector -> IO Double -- | 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
--   
withPrintFn :: CSvmPrintFn -> IO a -> IO a type CSvmPrintFn = CString -> IO ()