Browse Source

small improvement

master
parent
commit
659ee02991
  1. 2
      datasets/yml
  2. 8
      src/Main.hs
  3. 9
      src/YML/LinearGradient.hs
  4. 3
      test/Hml/Test.hs

2
datasets/yml

@ -1 +1 @@
../dist/dist-sandbox-8de7a798/build/yml/yml
../dist/dist-sandbox-171f1845/build/yml/yml

8
src/Main.hs

@ -10,11 +10,13 @@ import YML.LinearGradient
-- and try to read it and put its values inside a dataset data structure
main :: IO ()
main = do
(options,file) <- parseArgs
fileContent <- readFile file
(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

9
src/YML/LinearGradient.hs

@ -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

3
test/Hml/Test.hs

@ -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…
Cancel
Save