Copyright(c) Fabricio Olivetti de Franca 2020
LicenseGPL-3
Maintainerfabricio.olivetti@gmail.com
Stabilityexperimental
PortabilityPOSIX
Safe HaskellNone

IT

Description

An IT expression represents a function of the form:

\[ f(x) = \sum_{i}{w_i \cdot t_i(\prod_{j}{x_j^{k_{ij}})}} \]

with \(t_i\) being a transformation function.

Any given expression can be represented by a list of terms, with each term being composed of a transformatioon function and an interaction. The transformation function is represented by a Transformation sum type. The interaction is represented as an `IntMap Int` where the key is the predictor index and the value is the strength of the predictor in this term. Strengths with a value of zero are omitted.

Synopsis

Documentation

type Interaction = IntMap Int Source #

The Interaction type is a map where a key, value pair (i,p) indicates that the i-th variable should be raised to the power of p.

data Transformation Source #

The Transformation type describes the function that should be evaluated. The evaluation is defined in Eval module.

Constructors

Id 
Sin 
Cos 
Tan 
Tanh 
Sqrt 
SqrtAbs 
Log 
Exp 
Log1p 

Instances

Instances details
Eq Transformation Source # 
Instance details

Defined in IT

Ord Transformation Source # 
Instance details

Defined in IT

Read Transformation Source # 
Instance details

Defined in IT

Methods

readsPrec :: Int -> ReadS Transformation

readList :: ReadS [Transformation]

readPrec :: ReadPrec Transformation

readListPrec :: ReadPrec [Transformation]

Show Transformation Source # 
Instance details

Defined in IT

Methods

showsPrec :: Int -> Transformation -> ShowS

show :: Transformation -> String

showList :: [Transformation] -> ShowS

data Term Source #

A Term is the product type of a Transformation and an Interaction.

Instances

Instances details
Eq Term Source #

Two terms are equal if their interactions are equal this instance is used for the mutation operation to avoid adding two interactions with the same value on the same expression.

Instance details

Defined in IT

Methods

(==) :: Term -> Term -> Bool

(/=) :: Term -> Term -> Bool

Read Term Source # 
Instance details

Defined in IT

Methods

readsPrec :: Int -> ReadS Term

readList :: ReadS [Term]

readPrec :: ReadPrec Term

readListPrec :: ReadPrec [Term]

Show Term Source # 
Instance details

Defined in IT

Methods

showsPrec :: Int -> Term -> ShowS

show :: Term -> String

showList :: [Term] -> ShowS

type Expr = [Term] Source #

An Expr is just a list of Terms.

type Column a = Vector a Source #

A Column of a data set is stored as a LA.Vector to avoid conversions during the fitting of the coefficients.

type Dataset a = Vector (Column a) Source #

The Dataset is a Vector of Columns for efficiency. TODO: try Repa or Accelerate for large data sets.

prettyPrint Source #

Arguments

:: ((Int, Int) -> String)

A function that converts an interaction to a string

-> (Transformation -> String)

A function that converts a transformation to a string

-> Expr

The expression to convert to string

-> [Double]

The fitted coefficients

-> String

A string representing the expression

Base interface for converting an expression to string

toExprStr :: Expr -> [Double] -> String Source #

Converts an expression to a readable format

toPython :: Expr -> [Double] -> String Source #

Converts an expression to a numpy compatible format

Internal functions

removeIthTerm :: Int -> Expr -> Expr Source #

remove the i-th term of an expression.

getIthTerm :: Int -> Expr -> Maybe Term Source #

returns the i-th term of an expression.

getInteractions :: Term -> Interaction Source #

return the interactions of a term

exprLength :: Expr -> [Double] -> Int Source #

termLength :: Term -> Int Source #

The length of a term is the interaction length plus 1 if the transformation function is not Id.

interactionLength :: Interaction -> Int Source #

The interaction length is calculated as: +2 for every exponent different from 0 and 1 (^k) +1 for every nonzero exponent, except for the first (*) +1 for every nonzero exponent (x_i)