mltool-0.2.0.1: Machine Learning Toolbox

Copyright(c) Alexander Ignatyev 2016
LicenseBSD-3
Stabilityexperimental
PortabilityPOSIX
Safe HaskellNone
LanguageHaskell2010

MachineLearning.NeuralNetwork

Description

Simple Neural Networks.

Synopsis

Documentation

class Model a where Source #

Minimal complete definition

hypothesis, cost, gradient

Methods

hypothesis :: a -> Matrix -> Vector -> Vector Source #

Hypothesis function, a.k.a. score function (for lassifition problem) Takes X (m x n) and theta (n x 1), returns y (m x 1).

cost :: a -> Regularization -> Matrix -> Vector -> Vector -> R Source #

Cost function J(Theta), a.k.a. loss function. It takes regularizarion parameter, matrix X (m x n), vector y (m x 1) and vector theta (n x 1).

gradient :: a -> Regularization -> Matrix -> Vector -> Vector -> Vector Source #

Gradient function. It takes regularizarion parameter, X (m x n), y (m x 1) and theta (n x 1). Returns vector of gradients (n x 1).

newtype NeuralNetworkModel Source #

Neural Network Model. Takes neural network topology as a constructor argument.

Constructors

NeuralNetwork Topology 

calcAccuracy :: Vector -> Vector -> R Source #

Calculates accuracy of Classification predictions. Takes vector expected y and vector predicted y. Returns number from 0 to 1, the closer to 1 the better accuracy. Suitable for both Classification Types: Binary and Multiclass.

data Topology Source #

Neural network topology has at least 2 elements: numver of input and number of outputs. And sizes of hidden layers between 2 elements.

initializeTheta :: Int -> Topology -> Vector Source #

Create and initialize weights vector with random values for given neural network topology. Takes a seed to initialize generator of random numbers as a first parameter.

initializeThetaIO :: Topology -> IO Vector Source #

Create and initialize weights vector with random values for given neural network topology inside IO Monad.

initializeThetaM :: RandomGen g => Topology -> Rand g Vector Source #

Create and initialize weights vector with random values for given neural network topology inside RandomMonad.

data Regularization Source #

Regularization

Constructors

RegNone

No regularization

L2 R

L2 Regularization