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

MachineLearning.TIR

Description

The TIR expression represents a function of the form:

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

with \(t_i\) being a transformation function, \(g\) an invertible function, \(w_i\) a linear coefficient, \(k_{ij}\) the interaction strength.

Any given expression can be represented by two lists of terms, with each term being composed of a transformatioon function and an interaction. The transformation function is represented by a Function sum type. The interaction is represented as a list of tuple of ints 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

data TIR Source #

TIR is a record type composed of the external function _funY of type Function, numerator _p and denominator _q of type Sigma

Constructors

TIR 

Fields

Instances

Instances details
Show TIR Source # 
Instance details

Defined in MachineLearning.TIR

Methods

showsPrec :: Int -> TIR -> ShowS

show :: TIR -> String

showList :: [TIR] -> ShowS

NFData TIR Source # 
Instance details

Defined in MachineLearning.TIR

Methods

rnf :: TIR -> ()

type Sigma = [Pi] Source #

Sigma is just a list of terms Pi

type Pi = (Double, Function, [(Int, Int)]) Source #

Pi is a triple composed of a coefficient, a Function and a list of tuples where `(ix, k)` represents `x ! ix ^ k`.

randomRng :: (Int, Int) -> Rnd Int Source #

generates a random integer within the specified range.

randomRngNZ :: (Int, Int) -> Rnd Int Source #

generates a random integer within the specified range excluding zero.

randomFrom :: [a] -> Rnd a Source #

picks a random element from a list.

randomVar :: MutationCfg -> Rnd (Maybe Int, MutationCfg) Source #

returns a random index of variables provided by the mutation configuration.

randomVars :: MutationCfg -> Rnd [(Int, Int)] Source #

returns a list of random interactions (tuples of variables indeces and exponentes) with parameters provided by the mutation configuration.

randomPi :: MutationCfg -> Rnd (Maybe Pi) Source #

returns a random Pi

randomSigma :: MutationCfg -> Int -> Rnd (Sigma, Int) Source #

returns a random Sigma

randomTIR :: MutationCfg -> Rnd TIR Source #

returns a random TIR expression

type Column a = Vector a Source #

We store thee dataset as a vector of columns. Each vector is stored a Storable-based vector.

type Dataset a = Vector (Column a) Source #

A dataset is a Vector of Column

type Constraint = SRTree Int Double -> Double Source #

A constraint is a function that gets a symbolic tree as an input and returns non negative Double representing how much a constraint was violated.

data Individual Source #

An individual in the population is composed of the chromossome, a vector of fitness, a list of coefficients (for multiclass problems it stores one vector of coefficient per class), the constraint violation, the size of the expression, and the penalty value.

Constructors

Individual 

Fields

Instances

Instances details
NFData Individual Source # 
Instance details

Defined in MachineLearning.TIR

Methods

rnf :: Individual -> ()

Solution Individual Source # 
Instance details

Defined in MachineLearning.TIR

Methods

_getFitness :: Individual -> Double

_isFeasible :: Individual -> Bool

Eq Individual Source # 
Instance details

Defined in MachineLearning.TIR

Methods

(==) :: Individual -> Individual -> Bool

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

Ord Individual Source # 
Instance details

Defined in MachineLearning.TIR

createIndividual :: TIR -> Individual Source #

creates an unevaluated individual.

penalizedFit :: Individual -> Double Source #

calculates the penalized fitness.

replaceConsts :: TIR -> Vector Double -> TIR Source #

replaces the coefficients of a TIR expression

replaceWeight :: Pi -> State [Double] Pi Source #

assembleTree :: Double -> TIR -> SRTree Int Double Source #

creates a symbolic tree from a TIR expression.

prettyPrintsolution :: Individual -> String Source #

pretty print a solution.