crf-chain1-constrained-0.6.0: First-order, constrained, linear-chain conditional random fields

Safe HaskellNone
LanguageHaskell98

Data.CRF.Chain1.Constrained.DAG.Train

Contents

Description

Provisional training module which works on sequential external data but transforms it to DAG internal data form.

Synopsis

Model

data CRF a b Source #

A conditional random field model with additional codec used for data encoding.

Constructors

CRF 

Fields

  • codec :: Codec a b

    The codec is used to transform data into internal representation, where each observation and each label is represented by a unique integer number.

  • model :: Model

    The actual model, which is a map from Features to potentials.

Instances
(Ord a, Ord b, Binary a, Binary b) => Binary (CRF a b) Source # 
Instance details

Defined in Data.CRF.Chain1.Constrained.DAG.Train

Methods

put :: CRF a b -> Put #

get :: Get (CRF a b) #

putList :: [CRF a b] -> Put #

Training

train Source #

Arguments

:: (Ord a, Ord b) 
=> SgdArgs

Args for SGD

-> Bool

Store dataset on a disk

-> ([SentL a b] -> Set b)

R0 construction

-> (AVec Lb -> [DAG () (X, Y)] -> [Feature])

Feature selection

-> IO [SentL a b]

Training data IO action

-> IO [SentL a b]

Evaluation data

-> IO (CRF a b)

Resulting model

Train the CRF using the stochastic gradient descent method.

The resulting model will contain features extracted with the user supplied extraction function. You can use the functions provided by the Data.CRF.Chain1.Constrained.Feature.Present and Data.CRF.Chain1.Constrained.Feature.Hidden modules for this purpose.

You also have to supply R0 construction method (e.g. oovChosen) which determines the contents of the default set of labels.

R0 construction

oovChosen :: Ord b => [SentL a b] -> Set b Source #

Collect labels assigned to OOV words.

anyChosen :: Ord b => [SentL a b] -> Set b Source #

Collect labels assigned to words in a dataset.

anyInterps :: Ord b => [SentL a b] -> Set b Source #

Collect interpretations (also labels assigned) of words in a dataset.

Utils

verifyDAG :: DAG a (X, Y) -> Maybe Error Source #

Check if the DAG satisfies all the desirable properties.

data Error Source #

Verification error.

Constructors

Malformed 
Cyclic 
SeveralSources [NodeID] 
SeveralTargets [NodeID] 
WrongBalance [NodeID]

Nodes for which the total sum of the incoming probabilities does not equal the total sum of the outgoing probabilities

Instances
Eq Error Source # 
Instance details

Defined in Data.CRF.Chain1.Constrained.DAG.Train

Methods

(==) :: Error -> Error -> Bool #

(/=) :: Error -> Error -> Bool #

Ord Error Source # 
Instance details

Defined in Data.CRF.Chain1.Constrained.DAG.Train

Methods

compare :: Error -> Error -> Ordering #

(<) :: Error -> Error -> Bool #

(<=) :: Error -> Error -> Bool #

(>) :: Error -> Error -> Bool #

(>=) :: Error -> Error -> Bool #

max :: Error -> Error -> Error #

min :: Error -> Error -> Error #

Show Error Source # 
Instance details

Defined in Data.CRF.Chain1.Constrained.DAG.Train

Methods

showsPrec :: Int -> Error -> ShowS #

show :: Error -> String #

showList :: [Error] -> ShowS #