tffm/utils.py
def powers_and_coefs(order):
    """For a `order`-way FM returns the powers and their coefficients needed to
    compute model equation efficiently
    """
    decompositions, _ = get_shorter_decompositions(np.ones(order))
    graph = defaultdict(lambda: list())
    graph_reversed = defaultdict(lambda: list())
    for dec in decompositions:
        parents, weights = get_shorter_decompositions(dec)
        for i in range(len(parents)):
            graph[parents[i]].append((dec, weights[i]))
            graph_reversed[dec].append((parents[i], weights[i]))

    topo_order = sort_topologically(graph, decompositions)

    final_coefs = defaultdict(lambda: 0)
    for node in topo_order:
        final_coefs[node] += initial_coefficient(node)
        for p, w in graph_reversed[node]:
            final_coefs[p] -= w * final_coefs[node]
    powers_and_coefs_list = []
    # for dec, c in final_coefs.iteritems():
    for dec, c in final_coefs.items():
        in_pows, out_pows = np.unique(dec, return_counts=True)
        powers_and_coefs_list.append((in_pows, out_pows, c))

    return powers_and_coefs_list
For a `order`-way FM returns the powers and their coefficients needed to
    compute model equation efficiently
    
For a `order`-way FM returns the powers and their coefficients needed to
compute model equation efficiently
For a ` order ` - way FM returns the powers and their coefficients needed to compute model equation efficiently
def powers_and_coefs(order):
    decompositions, _ = get_shorter_decompositions(np.ones(order))
    graph = defaultdict(lambda: list())
    graph_reversed = defaultdict(lambda: list())
    for dec in decompositions:
        parents, weights = get_shorter_decompositions(dec)
        for i in range(len(parents)):
            graph[parents[i]].append((dec, weights[i]))
            graph_reversed[dec].append((parents[i], weights[i]))
    topo_order = sort_topologically(graph, decompositions)
    final_coefs = defaultdict(lambda: 0)
    for node in topo_order:
        final_coefs[node] += initial_coefficient(node)
        for p, w in graph_reversed[node]:
            final_coefs[p] -= w * final_coefs[node]
    powers_and_coefs_list = []
    for dec, c in final_coefs.items():
        in_pows, out_pows = np.unique(dec, return_counts=True)
        powers_and_coefs_list.append((in_pows, out_pows, c))
    return powers_and_coefs_list
def powers_and_coefs ( order ) : decompositions , _ = get_shorter_decompositions ( np . ones ( order ) ) graph = defaultdict ( lambda : list ( ) ) graph_reversed = defaultdict ( lambda : list ( ) ) for dec in decompositions : parents , weights = get_shorter_decompositions ( dec ) for i in range ( len ( parents ) ) : graph [ parents [ i ] ] . append ( ( dec , weights [ i ] ) ) graph_reversed [ dec ] . append ( ( parents [ i ] , weights [ i ] ) ) topo_order = sort_topologically ( graph , decompositions ) final_coefs = defaultdict ( lambda : 0 ) for node in topo_order : final_coefs [ node ] += initial_coefficient ( node ) for p , w in graph_reversed [ node ] : final_coefs [ p ] -= w * final_coefs [ node ] powers_and_coefs_list = [ ] for dec , c in final_coefs . items ( ) : in_pows , out_pows = np . unique ( dec , return_counts = True ) powers_and_coefs_list . append ( ( in_pows , out_pows , c ) ) return powers_and_coefs_list
For a `order`-way FM returns the powers and their coefficients needed to
compute model equation efficiently
For a ` order ` - way FM returns the powers and their coefficients needed to compute model equation efficiently
"""For a `order`-way FM returns the powers and their coefficients needed to
    compute model equation efficiently
    """ # for dec, c in final_coefs.iteritems():
order