Safe Haskell | None |
---|
The HomTrainer
class forms the base of the HLearn library. It represents homomorphisms from a free monoid/group to any other structure. This captures our intuitive notion of how data mining and machine learning algorithms should behave, but in a way that allows for the easy creation of parallel and online algorithms.
Unfortunately, we must slightly complicate the matter by also introducing the Model
class. Many learning algorithms take some sort of parameters, and we need the model class to define what those parameters should look like.
- class Model modelparams model | modelparams -> model, model -> modelparams where
- getparams :: model -> modelparams
- class Model modelparams model => DefaultModel modelparams model where
- defparams :: modelparams
- class (Semigroup model, Monoid model, Model modelparams model) => HomTrainer modelparams datapoint model where
- train1dp' :: modelparams -> datapoint -> model
- train' :: (Functor container, FunctorConstraint container model, FunctorConstraint container datapoint, Foldable container, FoldableConstraint container model) => modelparams -> container datapoint -> model
- add1dp :: model -> datapoint -> model
- addBatch :: (Functor container, FunctorConstraint container model, FunctorConstraint container datapoint, Foldable container, FoldableConstraint container model) => model -> container datapoint -> model
- class (DefaultModel modelparams model, HomTrainer modelparams datapoint model) => DefaultHomTrainer modelparams datapoint model where
- train1dp :: datapoint -> model
- train :: (Functor container, FunctorConstraint container model, FunctorConstraint container datapoint, Foldable container, FoldableConstraint container model) => container datapoint -> model
- type Labeled var label = (label, var)
- type Weighted var = (var, Double)
- class (Hashable label, Binary label, Ord label, Eq label, Show label, Read label) => Label label
- module Control.DeepSeq
- module Data.Hashable
- module Data.Binary
Parameters
class Model modelparams model | modelparams -> model, model -> modelparams whereSource
Every model has at least one data type that that fully describes its parameters. Many models do not actually *need* any parameters, in which case they will simply use an empty data type for modelparams.
class Model modelparams model => DefaultModel modelparams model whereSource
For those algorithms that do not require parameters (or that have reasonable default parameters), this class lets us use a more convenient calling notation.
HomTrainer
class (Semigroup model, Monoid model, Model modelparams model) => HomTrainer modelparams datapoint model whereSource
A minimal complete definition of the class is the singleton trainer 'train1dp\''
train1dp' :: modelparams -> datapoint -> modelSource
The singleton trainer
train' :: (Functor container, FunctorConstraint container model, FunctorConstraint container datapoint, Foldable container, FoldableConstraint container model) => modelparams -> container datapoint -> modelSource
The batch trainer
add1dp :: model -> datapoint -> modelSource
The online trainer
addBatch :: (Functor container, FunctorConstraint container model, FunctorConstraint container datapoint, Foldable container, FoldableConstraint container model) => model -> container datapoint -> modelSource
The batch online trainer; will be more efficient than simply calling add1dp
for each element being added
class (DefaultModel modelparams model, HomTrainer modelparams datapoint model) => DefaultHomTrainer modelparams datapoint model whereSource
Provides parameterless functions for those training algorithms that do not require parameters
train1dp :: datapoint -> modelSource
A singleton trainer that doesn't require parameters (uses defparams
)
train :: (Functor container, FunctorConstraint container model, FunctorConstraint container datapoint, Foldable container, FoldableConstraint container model) => container datapoint -> modelSource
A batch trainer that doesn't require parameters (uses defparams
)
(DefaultModel modelparams model, HomTrainer modelparams datapoint model) => DefaultHomTrainer modelparams datapoint model |
Type synonyms
class (Hashable label, Binary label, Ord label, Eq label, Show label, Read label) => Label label Source
I only ever expect labels of type Bool, Int, and String, but it may be convenient to use other types as well for something. This class and instance exist so that we have some reasonable assumptions about what properties labels should have for our other classes to work with. It also keeps us from writing so many constraints.
module Control.DeepSeq
module Data.Hashable
module Data.Binary