def calc_tree_depth(n_features, max_depth=5):
    """Calculate tree depth
    Args:
        n_features (int): Number of features
        max_depth (int, optional): Max depth tree. Defaults to 15.
    Returns:
        [int]: Final depth tree
    """
    # Designed using balls-in-bins probability. See the paper for details.
    m = float(n_features)
    depth = 0
    expected_empty = m   # the number of unique attributes not selected so far
    while expected_empty > m / 2:   # repeat until we have less than half the attributes being empty
        expected_empty = m * ((m - 1) / m) ** depth
        depth += 1
    # the above was only for half the numerical attributes. now add half the categorical attributes
    return min(max_depth, depth)