HLearn-algebra-0.0.1: Algebraic foundation for the homomorphic learning

Safe HaskellNone

HLearn.Algebra.Models

Contents

Description

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.

Synopsis

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.

Methods

getparams :: model -> modelparamsSource

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.

Methods

defparams :: modelparamsSource

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\''

Methods

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

Methods

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)

Instances

(DefaultModel modelparams model, HomTrainer modelparams datapoint model) => DefaultHomTrainer modelparams datapoint model 

Type synonyms

type Labeled var label = (label, var)Source

type Weighted var = (var, Double)Source

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.

Instances

(Hashable label, Binary label, Ord label, Eq label, Show label, Read label) => Label label