Copyright | (c) Fabricio Olivetti de Franca 2022 |
---|---|
License | GPL-3 |
Maintainer | fabricio.olivetti@gmail.com |
Stability | experimental |
Portability | POSIX |
Safe Haskell | Safe-Inferred |
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
- data TIR = TIR {}
- type Sigma = [Pi]
- type Pi = (Double, Function, [(Int, Int)])
- randomRng :: (Int, Int) -> Rnd Int
- randomRngNZ :: (Int, Int) -> Rnd Int
- randomFrom :: [a] -> Rnd a
- randomVar :: MutationCfg -> Rnd (Maybe Int, MutationCfg)
- randomVars :: MutationCfg -> Rnd [(Int, Int)]
- randomPi :: MutationCfg -> Rnd (Maybe Pi)
- randomSigma :: MutationCfg -> Int -> Rnd (Sigma, Int)
- randomTIR :: MutationCfg -> Rnd TIR
- type Column a = Vector a
- type Dataset a = Vector (Column a)
- type Constraint = SRTree Int Double -> Double
- data Individual = Individual {}
- createIndividual :: TIR -> Individual
- penalizedFit :: Individual -> Double
- replaceConsts :: TIR -> Vector Double -> TIR
- replaceWeight :: Pi -> State [Double] Pi
- assembleTree :: Double -> TIR -> SRTree Int Double
- prettyPrintsolution :: Individual -> String
Documentation
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`.
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.
randomSigma :: MutationCfg -> Int -> Rnd (Sigma, Int) Source #
returns a random Sigma
type Column a = Vector a Source #
We store thee dataset as a vector of columns.
Each vector is stored a Storable
-based vector.
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.
Instances
NFData Individual Source # | |
Defined in MachineLearning.TIR rnf :: Individual -> () | |
Solution Individual Source # | |
Defined in MachineLearning.TIR _getFitness :: Individual -> Double _isFeasible :: Individual -> Bool | |
Eq Individual Source # | |
Defined in MachineLearning.TIR (==) :: Individual -> Individual -> Bool (/=) :: Individual -> Individual -> Bool | |
Ord Individual Source # | |
Defined in MachineLearning.TIR compare :: Individual -> Individual -> Ordering (<) :: Individual -> Individual -> Bool (<=) :: Individual -> Individual -> Bool (>) :: Individual -> Individual -> Bool (>=) :: Individual -> Individual -> Bool max :: Individual -> Individual -> Individual min :: Individual -> Individual -> Individual |
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.