Skip to content

Commit

Permalink
Uploaded v1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeizbicki committed Jul 27, 2013
1 parent 2a2501b commit 89ce26a
Show file tree
Hide file tree
Showing 16 changed files with 193 additions and 1,677 deletions.
6 changes: 3 additions & 3 deletions HLearn-algebra/HLearn-algebra.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ bug-reports: http://github.com/mikeizbicki/HLearn/issues
Library
Build-Depends:
base >= 3 && < 5,
ConstraintKinds >= 0.1.0,
ConstraintKinds >= 1.1.0,
vector-heterogenous >= 0.1.1,
template-haskell,

Expand Down Expand Up @@ -57,9 +57,9 @@ Library
BangPatterns
TypeOperators
GeneralizedNewtypeDeriving
DataKinds
--DataKinds
TypeFamilies
PolyKinds
--PolyKinds
StandaloneDeriving
GADTs
KindSignatures
Expand Down
34 changes: 31 additions & 3 deletions HLearn-algebra/src/HLearn/Algebra/Models/HomTrainer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ module HLearn.Algebra.Models.HomTrainer
HomTrainer (..)
, WeightedHomTrainer (..)
, NumDP(..)

-- * useful functions
, sub1dp
, subBatch
, sub1dpW
, subBatchW

)
where
Expand Down Expand Up @@ -88,6 +94,8 @@ class (Monoid model) => HomTrainer model where
-------------------------------------------------------------------------------
-- WeightedHomTrainer

type WeightedDatapoint model = (Ring model, Datapoint model)

class (Module model, HomTrainer model) =>
WeightedHomTrainer model
where
Expand All @@ -99,12 +107,32 @@ class (Module model, HomTrainer model) =>
container (Ring model,Datapoint model) -> model
trainW = batch train1dpW

add1dpW :: model -> (Ring model,Datapoint model) -> model
add1dpW :: model -> WeightedDatapoint model -> model
add1dpW = online $ unbatch $ offline addBatchW

addBatchW :: (Foldable container, Functor container) =>
model -> container (Ring model,Datapoint model) -> model
model -> container (WeightedDatapoint model) -> model
addBatchW = online trainW

instance (Module model, HomTrainer model) => WeightedHomTrainer model


-------------------------------------------------------------------------------
-- helper functions

-- | subtracts a single data point from the model
sub1dp :: (Group model, HomTrainer model) => model -> Datapoint model -> model
sub1dp m dp = m <> inverse (train1dp dp)

-- | subtracts a multiple data point from the model
subBatch :: (Group model, HomTrainer model, Foldable container, Functor container) =>
model -> container (Datapoint model) -> model
subBatch m dpL = m <> inverse (train dpL)

-- | subtracts a single weighted data point from the model
sub1dpW :: (Group model, WeightedHomTrainer model) => model -> WeightedDatapoint model -> model
sub1dpW m dp = m <> inverse (train1dpW dp)

-- | subtracts multiple weighted data points from the model
subBatchW :: (Group model, WeightedHomTrainer model, Foldable container, Functor container) =>
model -> container (WeightedDatapoint model) -> model
subBatchW m dpL = m <> inverse (trainW dpL)
4 changes: 3 additions & 1 deletion HLearn-algebra/src/HLearn/Algebra/Structures/Free/Bagging.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{-# LANGUAGE DataKinds #-}

module HLearn.Algebra.Structures.Free.Bagging
( Bagging
, Bagging'
Expand Down Expand Up @@ -57,4 +59,4 @@ instance
where
n = fromIntegral $ fromSing (sing :: Sing n)
seed = fromIntegral $ fromSing (sing :: Sing seed)
(offset,g) = random $ mkStdGen $ hash dp + seed
(offset,g) = random $ mkStdGen $ hash dp + seed
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{-# LANGUAGE EmptyDataDecls #-}
{-# LANGUAGE PolyKinds #-}

module HLearn.Algebra.Structures.Free.FreeHomTrainer
( FreeHomTrainer (..)
Expand Down Expand Up @@ -71,4 +72,4 @@ instance

train1dp dp = FreeHomTrainer'
{ modelL = FreeModule $ Map.singleton (lame_train dp) 1
}
}
1 change: 1 addition & 0 deletions HLearn-algebra/src/HLearn/Algebra/Types/Indexing.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE DataKinds #-}
module HLearn.Algebra.Types.Indexing
(
Index(..)
Expand Down
1,601 changes: 1 addition & 1,600 deletions HLearn-algebra/src/HLearn/Algebra/Types/Nat1.hs

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions HLearn-algebra/src/HLearn/Algebra/Types/Nat1Generator.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ data Nat1 = Zero | Succ Nat1

decl :: String
decl = concat $ map (\x -> x++"\n")
[ "-- | This module was automatically generated by Nat1Generator.hs"
[ "{-# LANGUAGE DataKinds #-}"
, "-- | This module was automatically generated by Nat1Generator.hs"
, "module HLearn.Algebra.Types.Nat1 where"
, "import GHC.TypeLits"
, "data Nat1Box (n::Nat1) = Nat1Box"
Expand All @@ -26,7 +27,7 @@ string_FromNat1 :: Int -> String
string_FromNat1 i = "type instance FromNat1 ("++show (int2Nat1 i)++") = "++show i

numNat :: Int
numNat = 1000
numNat = 200

main = do
putStrLn decl
Expand Down
4 changes: 2 additions & 2 deletions HLearn-distributions/HLearn-distributions.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ Library
BangPatterns
TypeOperators
GeneralizedNewtypeDeriving
DataKinds
--DataKinds
TypeFamilies
PolyKinds
--PolyKinds
StandaloneDeriving
GADTs
KindSignatures
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE DataKinds #-}
-- | The categorical distribution is used for discrete data. It is also sometimes called the discrete distribution or the multinomial distribution. For more, see the wikipedia entry: <https://en.wikipedia.org/wiki/CatContainer_distribution>
module HLearn.Models.Distributions.Multivariate.Internal.CatContainer
{- (
Expand Down Expand Up @@ -217,4 +218,4 @@ ds= [ "test":::'g':::"foo":::HNil
, "toot":::'f':::"foo":::HNil
]

test = train ds :: CatContainer String (CatContainer Char (CatContainer String (Unital Double) Double) Double) Double
test = train ds :: CatContainer String (CatContainer Char (CatContainer String (Unital Double) Double) Double) Double
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE PolyKinds #-}
module HLearn.Models.Distributions.Multivariate.Internal.Container
( Container
, MultiContainer
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE DataKinds #-}
-- | Used for ignoring data
module HLearn.Models.Distributions.Multivariate.Internal.Ignore
( Ignore
Expand Down Expand Up @@ -85,4 +86,4 @@ instance
Ignore' label (MarginalizeOut' (Nat1Box n) basedist) prob
marginalizeOut' _ dist = Ignore' $ marginalizeOut' (undefined :: Nat1Box n) $ basedist dist

condition' _ dist dp = Ignore' $ condition' (undefined :: Nat1Box n) (basedist dist) dp
condition' _ dist dp = Ignore' $ condition' (undefined :: Nat1Box n) (basedist dist) dp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{-# LANGUAGE DataKinds #-}

-- | This module provides convenient TemplateHaskell functions for making type lens suitable for use with multivariate distributions.
--
-- Given a data type that looks like:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE DataKinds #-}
module HLearn.Models.Distributions.Multivariate.Internal.Unital
where

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE DataKinds #-}
-- | Adapts any distribution into one that can handle missing data
module HLearn.Models.Distributions.Univariate.Internal.MissingData
( MissingData
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE DataKinds #-}
-- | Kernel Density Estimation (KDE) is a generic and powerful method for estimating a probability distribution. See wikipedia for more information: <http://en.wikipedia.org/wiki/Kernel_density_estimation>
module HLearn.Models.Distributions.Univariate.KernelDensityEstimator
where
Expand Down
Loading

0 comments on commit 89ce26a

Please sign in to comment.