Lenter

Python 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 Python.

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)
def parametersBuilderConditionalVars(kmax,omax,qmax,ll,aa):
    ...

The repa builder is defined in module AlignmentPracticableRepa,

parametersBuilderConditionalVarsRepa :: 
  Integer -> Integer -> Integer -> Set.Set Variable -> HistoryRepa -> 
  Maybe (Map.Map (Set.Set Variable) Double)
def parametersBuilderConditionalVarsRepa(kmax,omax,qmax,ll,aa):
  ...

Conditional entropy fud decomper

The repa conditional entropy fud decomper is defined in module AlignmentPracticableRepa,

parametersSystemsHistoryRepasDecomperConditionalFmaxRepa :: 
  Integer -> Integer -> Integer -> System -> Set.Set Variable -> HistoryRepa -> 
  Maybe (System, DecompFud)
def parametersSystemsHistoryRepasDecomperConditionalFmaxRepa(kmax,omax,fmax,uu,ll,aa):
    ...
    def lenter(ll,aa):
        return list(parametersBuilderConditionalVarsRepa(kmax,omax,1,ll,aa).items())
    ...
    def decomp(uu,zz,qq,f):
        if len(zz) == 0:
            nnr = lenter(ll,aa)
            if len(nnr) == 0:
                return (uu, decompFudEmpty())
            [(kkr,_)] = nnr
            ffr = vvff(uu,kkr,f)
            uur = uunion(uu,fsys(ffr))
            aar = apply(uur,ffr,aa)
            aa1 = trim(reduce(uur,fder(ffr)|ll,aar))
            zzr = tsgl((stateEmpty(),ffr))
            qq[(stateEmpty(),ffr)] = (aar,aa1)
            (ffr,nnr,kkr) = (None,None,None)
            return decomp(uur,zzr,qq,f+1)
        if fmax > 0 and f > fmax:
            return (uu,zzdf(zz))
        mm = []
        for (nn,yy) in treesPlaces(zz):
            (rr,ff) = nn[-1]
            (bb,bb1) = qq[(rr,ff)]
            tt = dom(treesRoots(yy))
            for (ss,a) in aall(red(bb1,fder(ff))):
                if a > 0 and ss not in tt:
                    e = a * ent(red(mul(bb1,unit(sset([ss]))),ll))
                    if e > rounding:
                        mm.append((e,(nn,ss,bb)))
        if len(mm) == 0:
            return (uu,zzdf(zz))
        mm.sort(key = lambda x: x[0])
        (_,(nn,ss,bb)) = mm[-1]
        cc = hrhrred(select(uu,ss,bb),vv)
        nnc = lenter(ll,cc)
        [(kkc,_)] = nnc
        ffc = vvff(uu,kkc,f)
        uuc = uunion(uu,fsys(ffc))
        ccc = apply(uuc,ffc,cc)
        cc1 = trim(reduce(uuc,fder(ffc)|ll,ccc))
        qq[(ss,ffc)] = (ccc,cc1)
        zzc = pathsTree(treesPaths(zz) + [nn+[(ss,ffc)]])
        (mm,cc,ffc,nnc,kkc) = (None,None,None,None,None)
        return decomp(uuc,zzc,qq,f+1)
    if kmax < 0 or omax < 0:
        return None
    return decomp(uu,emptyTree(),sdict(),1)
  ...

top