def draw_tree ( t , df , size = 10 , ratio = 0.6 , precision = 0 ) : s = export_graphviz ( t , out_file = None , feature_names = df . columns , filled = True , special_characters = True , rotate = True , precision = precision ) IPython . display . display ( graphviz . Source ( re . sub ( 'Tree {' , f'Tree {{ size={size}; ratio={ratio}' , s ) ) )
plot tree from random forest python
Draws a representation of a random forest in IPython . Parameters : ----------- t : The tree you wish to draw df : The data used to train the tree . This is used to get the names of the features .
def draw_tree(t, df, size=10, ratio=0.6, precision=0):
    """ Draws a representation of a random forest in IPython.
    Parameters:
    -----------
    t: The tree you wish to draw
    df: The data used to train the tree. This is used to get the names of the features.
    """
    s=export_graphviz(t, out_file=None, feature_names=df.columns, filled=True,
                      special_characters=True, rotate=True, precision=precision)
    IPython.display.display(graphviz.Source(re.sub('Tree {',
       f'Tree {{ size={size}; ratio={ratio}', s)))