small improvement
This commit is contained in:
parent
a825453e91
commit
659ee02991
4 changed files with 14 additions and 8 deletions
|
@ -1 +1 @@
|
|||
../dist/dist-sandbox-8de7a798/build/yml/yml
|
||||
../dist/dist-sandbox-171f1845/build/yml/yml
|
|
@ -13,8 +13,10 @@ main = do
|
|||
(options,file) <- parseArgs
|
||||
fileContent <- readFile file
|
||||
let trainingSet = parse fileContent
|
||||
print trainingSet
|
||||
-- print trainingSet
|
||||
putStr "Cost of training set using the null function: "
|
||||
print $ cost trainingSet (nullF trainingSet)
|
||||
putStr "Function minimizing the cost: "
|
||||
print $ gradientDescent (optionsToParameters options) trainingSet
|
||||
where
|
||||
optionsToParameters :: Options -> Parameters
|
||||
|
|
|
@ -3,16 +3,19 @@ module YML.LinearGradient where
|
|||
import Data.List (intercalate)
|
||||
import Data.Vector.Unboxed ((!))
|
||||
import qualified Data.Vector.Unboxed as V
|
||||
import Debug.Trace (trace)
|
||||
|
||||
import YML.Dataset
|
||||
|
||||
-- swap comments to show debug traces
|
||||
-- import Debug.Trace (trace)
|
||||
trace _ x = x
|
||||
|
||||
|
||||
data Parameters = Parameters { alpha :: R , threshold :: R} deriving Show
|
||||
|
||||
-- | Linear Function type
|
||||
data LinearFunction = LinearFunction {thetas :: V.Vector R}
|
||||
instance Show LinearFunction where
|
||||
show l = intercalate ", " $ map show $ V.toList (thetas l)
|
||||
show l = intercalate ", " $ map (take 5 . show) $ V.toList (thetas l)
|
||||
|
||||
-- | The null function (use the dataset to determine the number of features)
|
||||
nullF :: Dataset -> LinearFunction
|
||||
|
|
|
@ -6,7 +6,8 @@ import Test.HUnit hiding (Test)
|
|||
|
||||
import Test.Framework.Providers.QuickCheck2 (testProperty)
|
||||
|
||||
import Hml
|
||||
import Yml.Dataset
|
||||
import Yml.LinearGradient
|
||||
|
||||
hmlSuite :: Test
|
||||
hmlSuite = testGroup "Hml testing"
|
||||
|
|
Loading…
Reference in a new issue