HSvm 0.1.0.2.89 → 0.1.0.2.90
raw patch · 2 files changed
+23/−16 lines, 2 filesnew-uploaderPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Data.SVM: c :: Algorithm -> Double
- Data.SVM: cacheSize :: ExtraParam -> Double
- Data.SVM: coef0 :: KernelType -> Double
- Data.SVM: degree :: KernelType -> Int
- Data.SVM: epsilon :: Algorithm -> Double
- Data.SVM: gamma :: KernelType -> Double
- Data.SVM: nu :: Algorithm -> Double
- Data.SVM: probability :: ExtraParam -> Int
- Data.SVM: shrinking :: ExtraParam -> Int
- Data.SVM.Raw: c :: CSvmParameter -> CDouble
- Data.SVM.Raw: cache_size :: CSvmParameter -> CDouble
- Data.SVM.Raw: coef0 :: CSvmParameter -> CDouble
- Data.SVM.Raw: degree :: CSvmParameter -> CInt
- Data.SVM.Raw: eps :: CSvmParameter -> CDouble
- Data.SVM.Raw: gamma :: CSvmParameter -> CDouble
- Data.SVM.Raw: index :: CSvmNode -> CInt
- Data.SVM.Raw: instance Show CKernelType
- Data.SVM.Raw: instance Show CSvmParameter
- Data.SVM.Raw: instance Show CSvmType
- Data.SVM.Raw: instance Storable CKernelType
- Data.SVM.Raw: instance Storable CSvmNode
- Data.SVM.Raw: instance Storable CSvmParameter
- Data.SVM.Raw: instance Storable CSvmProblem
- Data.SVM.Raw: instance Storable CSvmType
- Data.SVM.Raw: kernel_type :: CSvmParameter -> CKernelType
- Data.SVM.Raw: l :: CSvmProblem -> CInt
- Data.SVM.Raw: nr_weight :: CSvmParameter -> CInt
- Data.SVM.Raw: nu :: CSvmParameter -> CDouble
- Data.SVM.Raw: p :: CSvmParameter -> CDouble
- Data.SVM.Raw: probability :: CSvmParameter -> CInt
- Data.SVM.Raw: shrinking :: CSvmParameter -> CInt
- Data.SVM.Raw: svm_type :: CSvmParameter -> CSvmType
- Data.SVM.Raw: unCKernelType :: CKernelType -> CInt
- Data.SVM.Raw: unCSvmType :: CSvmType -> CInt
- Data.SVM.Raw: value :: CSvmNode -> CDouble
- Data.SVM.Raw: weight :: CSvmParameter -> Ptr CDouble
- Data.SVM.Raw: weight_label :: CSvmParameter -> Ptr CInt
- Data.SVM.Raw: x :: CSvmProblem -> Ptr (Ptr CSvmNode)
- Data.SVM.Raw: y :: CSvmProblem -> Ptr CDouble
+ Data.SVM: [c] :: Algorithm -> Double
+ Data.SVM: [cacheSize] :: ExtraParam -> Double
+ Data.SVM: [coef0] :: KernelType -> Double
+ Data.SVM: [degree] :: KernelType -> Int
+ Data.SVM: [epsilon] :: Algorithm -> Double
+ Data.SVM: [gamma] :: KernelType -> Double
+ Data.SVM: [nu] :: Algorithm -> Double
+ Data.SVM: [probability] :: ExtraParam -> Int
+ Data.SVM: [shrinking] :: ExtraParam -> Int
+ Data.SVM: crossValidate :: Algorithm -> KernelType -> Problem -> Int -> IO [Double]
+ Data.SVM: defaultExtra :: ExtraParam
+ Data.SVM: mergeExtra :: ExtraParam -> CSvmParameter -> CSvmParameter
+ Data.SVM.Raw: [c] :: CSvmParameter -> CDouble
+ Data.SVM.Raw: [cache_size] :: CSvmParameter -> CDouble
+ Data.SVM.Raw: [coef0] :: CSvmParameter -> CDouble
+ Data.SVM.Raw: [degree] :: CSvmParameter -> CInt
+ Data.SVM.Raw: [eps] :: CSvmParameter -> CDouble
+ Data.SVM.Raw: [gamma] :: CSvmParameter -> CDouble
+ Data.SVM.Raw: [index] :: CSvmNode -> CInt
+ Data.SVM.Raw: [kernel_type] :: CSvmParameter -> CKernelType
+ Data.SVM.Raw: [l] :: CSvmProblem -> CInt
+ Data.SVM.Raw: [nr_weight] :: CSvmParameter -> CInt
+ Data.SVM.Raw: [nu] :: CSvmParameter -> CDouble
+ Data.SVM.Raw: [p] :: CSvmParameter -> CDouble
+ Data.SVM.Raw: [probability] :: CSvmParameter -> CInt
+ Data.SVM.Raw: [shrinking] :: CSvmParameter -> CInt
+ Data.SVM.Raw: [svm_type] :: CSvmParameter -> CSvmType
+ Data.SVM.Raw: [unCKernelType] :: CKernelType -> CInt
+ Data.SVM.Raw: [unCSvmType] :: CSvmType -> CInt
+ Data.SVM.Raw: [value] :: CSvmNode -> CDouble
+ Data.SVM.Raw: [weight] :: CSvmParameter -> Ptr CDouble
+ Data.SVM.Raw: [weight_label] :: CSvmParameter -> Ptr CInt
+ Data.SVM.Raw: [x] :: CSvmProblem -> Ptr (Ptr CSvmNode)
+ Data.SVM.Raw: [y] :: CSvmProblem -> Ptr CDouble
+ Data.SVM.Raw: defaultCParam :: CSvmParameter
+ Data.SVM.Raw: instance Foreign.Storable.Storable Data.SVM.Raw.CKernelType
+ Data.SVM.Raw: instance Foreign.Storable.Storable Data.SVM.Raw.CSvmNode
+ Data.SVM.Raw: instance Foreign.Storable.Storable Data.SVM.Raw.CSvmParameter
+ Data.SVM.Raw: instance Foreign.Storable.Storable Data.SVM.Raw.CSvmProblem
+ Data.SVM.Raw: instance Foreign.Storable.Storable Data.SVM.Raw.CSvmType
+ Data.SVM.Raw: instance GHC.Show.Show Data.SVM.Raw.CKernelType
+ Data.SVM.Raw: instance GHC.Show.Show Data.SVM.Raw.CSvmParameter
+ Data.SVM.Raw: instance GHC.Show.Show Data.SVM.Raw.CSvmType
Files
- Data/SVM/Raw.hsc +15/−12
- HSvm.cabal +8/−4
Data/SVM/Raw.hsc view
@@ -1,9 +1,12 @@-{-# LANGUAGE ForeignFunctionInterface, GeneralizedNewtypeDeriving, +{-# LANGUAGE ForeignFunctionInterface, GeneralizedNewtypeDeriving, EmptyDataDecls #-} #include "svm.h" #include <stddef.h>++#if __GLASGOW_HASKELL__ < 800 #let alignment t = "%lu", (unsigned long)offsetof(struct {char x__; t (y__); }, y__)+#endif module Data.SVM.Raw where @@ -11,14 +14,14 @@ -- TODO verificare l'import import Foreign.Storable (Storable(..), peekByteOff, pokeByteOff)-import Foreign.C.Types (CDouble, CInt)+import Foreign.C.Types (CDouble (..), CInt (..) ) import Foreign.C.String (CString) import Foreign.Ptr(nullPtr, Ptr) import Foreign.ForeignPtr (FinalizerPtr) -data CSvmNode = CSvmNode { +data CSvmNode = CSvmNode { index:: CInt,- value:: CDouble + value:: CDouble } instance Storable CSvmNode where@@ -34,7 +37,7 @@ l:: CInt, y:: Ptr CDouble, x:: Ptr (Ptr CSvmNode)-} +} instance Storable CSvmProblem where sizeOf _ = #size struct svm_problem@@ -53,7 +56,7 @@ deriving (Storable, Show) #enum CSvmType, CSvmType, C_SVC, NU_SVC, ONE_CLASS, EPSILON_SVR, NU_SVR -newtype CKernelType = CKernelType {unCKernelType :: CInt} +newtype CKernelType = CKernelType {unCKernelType :: CInt} deriving (Storable, Show) #enum CKernelType, CKernelType, LINEAR, POLY, RBF, SIGMOID, PRECOMPUTED @@ -75,7 +78,7 @@ probability :: CInt } deriving Show -defaultCParam = CSvmParameter cSvc rbf 3 0 0 100 1e-3 1 +defaultCParam = CSvmParameter cSvc rbf 3 0 0 100 1e-3 1 0 nullPtr nullPtr 0.5 0.1 1 0 instance Storable CSvmParameter where@@ -96,7 +99,7 @@ p <- (#peek struct svm_parameter, p) ptr shrinking <- (#peek struct svm_parameter, degree) ptr probability <- (#peek struct svm_parameter, probability) ptr- return $ CSvmParameter svm_type kernel_type degree + return $ CSvmParameter svm_type kernel_type degree gamma coef0 cache_size eps c nr_weight weight_label weight nu p shrinking probability poke ptr (CSvmParameter svm_type kernel_type degree@@ -120,17 +123,17 @@ data CSvmModel --- TODO cambiare il return type da +-- TODO cambiare il return type da foreign import ccall unsafe "svm.h svm_train" c_svm_train :: Ptr CSvmProblem -> Ptr CSvmParameter -> IO (Ptr CSvmModel)- -foreign import ccall unsafe "svm.h svm_cross_validation" c_svm_cross_validation:: Ptr CSvmProblem -> Ptr CSvmParameter -> CInt -> Ptr CDouble -> IO () +foreign import ccall unsafe "svm.h svm_cross_validation" c_svm_cross_validation:: Ptr CSvmProblem -> Ptr CSvmParameter -> CInt -> Ptr CDouble -> IO ()+ foreign import ccall unsafe "svm.h svm_predict" c_svm_predict :: Ptr CSvmModel -> Ptr CSvmNode -> CDouble foreign import ccall unsafe "svm.h svm_save_model" c_svm_save_model :: CString -> Ptr CSvmModel -> IO CInt foreign import ccall unsafe "svm.h svm_load_model" c_svm_load_model :: CString -> IO (Ptr CSvmModel)- + foreign import ccall unsafe "svm.h svm_check_parameter" c_svm_check_parameter :: Ptr CSvmProblem -> Ptr CSvmParameter -> CString foreign import ccall unsafe "svm.h &svm_destroy_model" c_svm_destroy_model :: FinalizerPtr CSvmModel
HSvm.cabal view
@@ -1,16 +1,20 @@ Name: HSvm-Version: 0.1.0.2.89-Copyright: (c) 2009 Paolo Losi+Version: 0.1.0.2.90+Copyright: (c) 2009 Paolo Losi, 2017 Pavel Ryzhov Maintainer: Paolo Losi <paolo.losi@gmail.com> License: BSD3 License-File: LICENSE Author: Paolo Losi <paolo.losi@gmail.com> Category: Datamining, Classification-Synopsis: Haskell Bindings for libsvm +Synopsis: Haskell Bindings for libsvm Stability: alpha Build-Type: Simple-Cabal-Version: >= 1.2.1+Cabal-Version: >= 1.6 Extra-Source-Files: cbits/svm.cpp cbits/svm.h++source-repository head+ type: git+ location: https://github.com/paulrzcz/HSvm.git Library Build-Depends: base >= 4 && < 5, containers