Lenter

Haskell implementation of fast Practicable Inducers/Lenter

Sections

Conditional entropy tuple set builder

Conditional entropy fud decomper

Conditional entropy tuple set builder

The application of the conditional entropy tuple set builder is described in Haskell.

The conditional entropy tuple set builder parametersBuilderConditionalVars is defined in module AlignmentPracticable.

parametersBuilderConditionalVars :: 
  Integer -> Integer -> Integer -> Set.Set Variable -> Histogram -> 
  Maybe (Map.Map (Set.Set Variable) Double)

parametersBuilderConditionalVars kmax omax qmax ll aa
  | kmax < 0 || omax < 0 || qmax < 0 = Nothing
  | otherwise = Just $ bot qmax $ buildc rr rr
  where
    vvk = vars aa `minus` ll
    rr = bot omax $ llmm [(sgl w, ent (aa `red` (ll `add` w)) - ent (aa `red` (sgl w))) | w <- qqll vvk]
    buildc qq nn = if mm /= Map.empty then buildc mm (nn `Map.union` mm) else nn
      where
        pp = llqq [jj | (kk,e) <- mmll qq, e > 0, w <- qqll (vvk `minus` kk), let jj = kk `add` w]
        mm = bot omax $ llmm [(jj, ent (aa `red` (ll `union` jj)) - ent (aa `red` jj)) |
          jj <- qqll pp, card jj <= kmax]
  ...

The repa builder is defined in module AlignmentPracticableRepa,

parametersBuilderConditionalVarsRepa :: 
  Integer -> Integer -> Integer -> Set.Set Variable -> HistoryRepa -> 
  Maybe (Map.Map (Set.Set Variable) Double)

parametersBuilderConditionalVarsRepa kmax omax qmax ll aa
  | kmax < 0 || omax < 0 || qmax < 0 = Nothing
  | otherwise = Just $ bot qmax $ buildc rr rr
  where
    !z = fromIntegral $ historyRepasSize aa
    vvk = vars aa `minus` ll
    rr = bot omax $ llmm [(sgl w, ent (aa `red` (ll `add` w)) - ent (aa `red` (sgl w))) | w <- qqll vvk]
    buildc qq nn = if mm /= Map.empty then buildc mm (nn `Map.union` mm) else nn
      where
        pp = llqq [jj | (kk,e) <- mmll qq, e > 0, w <- qqll (vvk `minus` kk), let jj = kk `add` w]
        mm = bot omax $ llmm [(jj, ent (aa `red` (ll `union` jj)) - ent (aa `red` jj)) |
          jj <- qqll pp, card jj <= kmax]
  ...

An example of substrate analysis using the conditional entropy tuple set builder is described in Analysis of the UCI Machine Learning Repository Mushroom Data Set - Predicting edibility without modelling and Induced modelling of edibility.

Conditional entropy fud decomper

The application of the conditional entropy fud decomper is described in Haskell.

The conditional entropy fud decomper parametersSystemsDecomperConditional is defined in module AlignmentPracticable.

parametersSystemsDecomperConditional :: 
  Integer -> Integer -> System -> Set.Set Variable -> Histogram -> 
  Maybe (System, DecompFud)

as

parametersSystemsDecomperConditional kmax omax uu ll aa
  ...
  | otherwise = Just $ decomp uu emptyTree 1
  where
    decomp uu zz f s
      | zz == emptyTree && nnr == [] = (uu, decompFudEmpty)
      | zz == emptyTree = decomp uur zzr (f+1)
      | mm == [] = (uu, zzdf (zztrim zz)) 
      | otherwise = decomp uuc zzc (f+1)
      where
        nnr = lenter kmax omax 1 ll aa
        [(kkr,_)] = nnr
        ffr = if nnr /= [] then vvff uu kkr f else fudEmpty
        uur = uu `uunion` fsys ffr
        zzr = tsgl (stateEmpty,ffr)
        mm = [(e,nn,ss,bb) | (nn,yy) <- qqll (treesPlaces zz), 
                 let rrc = llsthis nn, let hhc = llfhis nn, let (_,ff) = last nn, ff /= fudEmpty,
                 ss <- qqll (cart uu (fder ff) `minus` dom (treesRoots yy)),
                 let xx = hhc `union` rrc `add` unit (sgl ss),
                 let bb = apply vv vv xx aa,
                 let e = fromRational (size bb) * ent (bb `red` ll)
                 e > 0]
        (_,nn,ss,bb) = last $ sort mm
        nnc = lenter kmax omax 1 ll bb
        [(kkc,_)] = nnc
        ffc = if nnr /= [] then vvff uu kkc f else fudEmpty
        uuc = uu `uunion` fsys ffc
        zzc = pathsTree $ treesPaths zz `add` (nn ++ [(ss,ffc)])
    lenter kmax omax qmax ll aa = mmll $ fromJust $ parametersBuilderConditionalVars kmax omax qmax ll aa
    ...

The repa decomper is defined in module AlignmentPracticableRepa,

parametersSystemsHistoryRepasDecomperConditionalFmaxRepa :: 
  Integer -> Integer -> Integer -> System -> Set.Set Variable -> HistoryRepa -> 
  Maybe (System, DecompFud)
parametersSystemsHistoryRepasDecomperConditionalFmaxRepa kmax omax fmax uu ll aa
  ...
  | otherwise = Just $ decomp uu emptyTree 1
  where
    vv = vars aa
    decomp uu zz f
      | zz == emptyTree && nnr == [] = (uu, decompFudEmpty)
      | zz == emptyTree = decomp uur zzr (f+1)
      | (fmax > 0 && f > fmax) || V.null mm || nnc == [] = (uu, zzdf zz) 
      | otherwise = decomp uuc zzc (f+1)
      where
        nnr = lenter kmax omax ll aa
        [(kkr,_)] = nnr
        ffr = vvff uu kkr f
        uur = uu `uunion` fsys ffr
        aar = apply uur ffr aa
        aa' = trim $ reduce uur (fder ffr `union` ll) aar
        zzr = tsgl ((stateEmpty,ffr),(aar, aa'))
        mm = V.fromList [(e,(nn,ss,bb)) | (nn,yy) <- qqll (treesPlaces zz), 
                 let ((_,ff),(bb,bb')) = last nn, 
                 let tt = dom (dom (treesRoots yy)),
                 (ss,a) <- aall (bb' `red` fder ff), a > 0, ss `notin` tt,
                 let e = fromRational a * ent (bb' `mul` unit (sgl ss) `red` ll), e > rounding]
        (_,(nn,ss,bb)) = V.head $ vectorPairsTop 1 mm
        cc = select uu ss bb `hrred` vv
        nnc = lenter kmax omax ll cc
        [(kkc,_)] = nnc
        ffc = vvff uu kkc f
        uuc = uu `uunion` fsys ffc
        ccc = apply uuc ffc cc
        cc' = trim $ reduce uuc (fder ffc `union` ll) ccc
        zzc = pathsTree $ treesPaths zz `add` (nn List.++ [((ss,ffc),(ccc, cc'))])
    lenter kmax omax ll aa = mmll $ fromJust $ parametersBuilderConditionalVarsRepa kmax omax 1 ll aa
  ...

top