regress-0.1.1: Linear and logistic regression through automatic differentiation

Safe HaskellNone
LanguageHaskell2010

Numeric.Regression.Logistic

Synopsis

Documentation

type Model f a = f a Source

A model using the given f to store parameters of type a. Can be thought of as some kind of vector throughough this package.

regress Source

Arguments

:: (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