def calc_mdl(yx_dist, y_dist):
    """
    Function calculates mdl with given label distributions. 

    yx_dist: list of dictionaries - for every split it contains a dictionary with label distributions
    y_dist: dictionary - all label distributions
    
    Reference:
    Igor Kononenko. On biases in estimating multi-valued attributes. In IJCAI, volume 95, pages 1034-1040, 1995.
    """
    prior = multinomLog2(y_dist.values())
    prior += multinomLog2([len(y_dist.keys()) - 1, sum(y_dist.values())])

    post = 0
    for x_val in yx_dist:
        post += multinomLog2([x_val.get(c, 0) for c in y_dist.keys()])
        post += multinomLog2([len(y_dist.keys()) - 1, sum(x_val.values())])
    return (prior - post) / float(sum(y_dist.values()))
def calc_mdl ( yx_dist , y_dist ) : prior = multinomLog2 ( y_dist . values ( ) ) prior += multinomLog2 ( [ len ( y_dist . keys ( ) ) - 1 , sum ( y_dist . values ( ) ) ] ) post = 0 for x_val in yx_dist : post += multinomLog2 ( [ x_val . get ( c , 0 ) for c in y_dist . keys ( ) ] ) post += multinomLog2 ( [ len ( y_dist . keys ( ) ) - 1 , sum ( x_val . values ( ) ) ] ) return ( prior - post ) / float ( sum ( y_dist . values ( ) ) )
Function calculates mdl with given label distributions. 

    yx_dist: list of dictionaries - for every split it contains a dictionary with label distributions
    y_dist: dictionary - all label distributions
    
    Reference:
    Igor Kononenko. On biases in estimating multi-valued attributes. In IJCAI, volume 95, pages 1034-1040, 1995.