Exemplo n.º 1
0
def exec_ex5(filepath, min_sup=0):
    """
    Executes CbO in a single line
    """
    dict_printer(
        CbO(FormalContextModel(filepath=filepath), min_sup=min_sup,
            lazy=False).poset)
Exemplo n.º 2
0
def exec_ex9(filepath, min_sup=0):
    """
    Executes NextClosure in a single line
    """
    dict_printer(
        LexEnumClosures(FormalContextModel(filepath=filepath),
                        min_sup=min_sup,
                        lazy=False).poset)
Exemplo n.º 3
0
def exec_ex6(filepath, theta, min_col):
    """
    Execute CbO over pattern structures

    Notice that the algorithm is different and it also works differently
    PSCbO lists objects one by one, in a bottom-up way
    """
    fctx = FormalContextModel(filepath=filepath,
                              transformer=List2IntervalsTransformer(int))
    MaxLengthIntervalPattern.THETA = theta
    MaxLengthIntervalPattern.MIN_COL = min_col
    dict_printer(PSCbO(fctx,
                       pattern=MaxLengthIntervalPattern,
                       lazy=False,
                       silent=False).poset,
                 transposed=True)
Exemplo n.º 4
0
def exec_ex10(filepath, min_sup=0):
    """
    Example 10 - Obtains the Duquenne-Guigues Canonical Base
    of Implications Rules with LecEnumClosures
    """

    canonical_base = CanonicalBase(
        FormalContextModel(filepath=filepath),
        min_sup=min_sup,
        lazy=False,
        silent=True
    )

    for rule, support in canonical_base.get_implications():
        ant, con = rule
        print('{:>10s} => {:10s}'.format(lst2str(ant), lst2str(con)), support)
Exemplo n.º 5
0
def exec_ex17(filepath, min_sup=0, output_fname=None):
    """
    Example 17: LexEnumClosures OnDisk - Streaming patterns to disk
    """
    ondisk_poset = LexEnumClosures(
        FormalContextModel(
            filepath=filepath
        ),
        min_sup=min_sup,
        ondisk=True,
        ondisk_kwargs={
            'output_path':'/tmp',
            'output_fname':output_fname
        },
        silent=True
    ).poset
    output_path = ondisk_poset.close()
    print ("\t=> Results stored in {}".format(output_path))
Exemplo n.º 6
0
def exec_ex20(filepath, min_sup=0, output_fname=None):
    """
    Example 20: Obtains the Duquenne-Guigues Canonical Base OnDisk - Streaming pattern to disk
    """

    canonical_base = CanonicalBase(FormalContextModel(filepath=filepath),
                                   min_sup=min_sup,
                                   lazy=False,
                                   silent=True,
                                   ondisk=True,
                                   ondisk_kwargs={
                                       'output_path': '/tmp',
                                       'output_fname': output_fname,
                                       'write_support': True,
                                       'write_extent': False
                                   })

    output_path = canonical_base.poset.close()

    for rule, support in canonical_base.get_implications():
        ant, con = rule
        print('{:10s} => {:10s}'.format(lst2str(ant), lst2str(con)), support)

    print("\t=> Pseudo closures stored in {}".format(output_path))