Safe Haskell | None |
---|---|

Language | Haskell2010 |

- type Model f a = f a
- regress :: (Traversable v, Applicative v, Foldable f, Applicative f, Ord a, Floating a) => a -> f a -> f (v a) -> Model v a -> [Model v a]

# Documentation

A model using the given `f`

to store parameters of type `a`

.
Can be thought of as some kind of vector throughough this
package.

:: (Traversable v, Applicative v, Foldable f, Applicative f, Ord a, Floating a) | |

=> a | learning rate |

-> f a | expect prediction for each observation |

-> f (v a) | input data for each observation |

-> Model v a | initial values for the model's parameters |

-> [Model v a] | stream of increasingly accurate values for the model's parameters |

Given some observed "predictions" `ys`

, the corresponding
input values `xs`

and initial values for the model's parameters `theta0`

,

regress ys xs theta0

returns a stream of values for the parameters that'll fit the data better and better.

Example:

ys_ex :: [Double] xs_ex :: [[Double]] (ys_ex, xs_ex) = unzip $ [ (1, [1, 1]) , (0, [-1, -2]) , (1, [2, 5]) , (0, [-1, 1]) , (1, [2, -1]) , (1, [1, -10]) , (0, [-0.1, 30]) ] t0 :: [Double] t0 = [1, 0.1] approxs' :: [Model [] Double] approxs' = learn 0.1 ys_ex xs_ex t0