woodpecker/sklearn/decisiontree/decision_tree_structure_classifier.py
def show_leaf_samples_by_class(self, figsize=None, leaf_sample_size=None, plot_ylim=None):
    """Show samples by class for each leaf.

    :param plot_ylim: int, optional
        The max value for oY. This is useful in case we have few leaves with big sample values which 'shadow'
        the other leaves values
    :param leaf_sample_size: int, optional
        The sample of leaves to plot. This is useful when the tree contains to many leaves and cannot be displayed
        clear in a plot.
    :param figsize: tuple of int, optional
        The plot size
    """

    self._calculate_leaf_nodes()
    leaf_samples = [(i, self.value[i][0][0], self.value[i][0][1], self.impurity[i]) for i in
                    range(0, self.node_count)
                    if (self.is_leaf[i])]
    index, leaf_samples_0, leaf_samples_1, impurity_sample = zip(*leaf_samples)

    if leaf_sample_size is None:
        leaf_sample_size = len(index)
    if figsize:
        plt.figure(figsize=figsize)
    p0 = plt.bar(range(0, len(index[:leaf_sample_size])), leaf_samples_0[:leaf_sample_size])
    p1 = plt.bar(range(0, len(index[:leaf_sample_size])), leaf_samples_1[:leaf_sample_size],
                 bottom=leaf_samples_0[:leaf_sample_size])

    plt.xticks(range(0, len(index)), index)

    if plot_ylim is not None:
        plt.ylim(0, plot_ylim)

    plt.xlabel("leaf node ids", size=20)
    plt.ylabel("samples", size=20)
    plt.grid()
    plt.legend((p0[0], p1[0]), ('class 0 samples', 'class 1 samples'))
Show samples by class for each leaf.

    :param plot_ylim: int, optional
        The max value for oY. This is useful in case we have few leaves with big sample values which 'shadow'
        the other leaves values
    :param leaf_sample_size: int, optional
        The sample of leaves to plot. This is useful when the tree contains to many leaves and cannot be displayed
        clear in a plot.
    :param figsize: tuple of int, optional
        The plot size
    
Show samples by class for each leaf.
Show samples by class for each leaf .
def show_leaf_samples_by_class(self, figsize=None, leaf_sample_size=None, plot_ylim=None):
    self._calculate_leaf_nodes()
    leaf_samples = [(i, self.value[i][0][0], self.value[i][0][1], self.impurity[i]) for i in
                    range(0, self.node_count)
                    if (self.is_leaf[i])]
    index, leaf_samples_0, leaf_samples_1, impurity_sample = zip(*leaf_samples)
    if leaf_sample_size is None:
        leaf_sample_size = len(index)
    if figsize:
        plt.figure(figsize=figsize)
    p0 = plt.bar(range(0, len(index[:leaf_sample_size])), leaf_samples_0[:leaf_sample_size])
    p1 = plt.bar(range(0, len(index[:leaf_sample_size])), leaf_samples_1[:leaf_sample_size],
                 bottom=leaf_samples_0[:leaf_sample_size])
    plt.xticks(range(0, len(index)), index)
    if plot_ylim is not None:
        plt.ylim(0, plot_ylim)
    plt.xlabel("leaf node ids", size=20)
    plt.ylabel("samples", size=20)
    plt.grid()
    plt.legend((p0[0], p1[0]), ('class 0 samples', 'class 1 samples'))
def show_leaf_samples_by_class ( self , figsize = None , leaf_sample_size = None , plot_ylim = None ) : self . _calculate_leaf_nodes ( ) leaf_samples = [ ( i , self . value [ i ] [ 0 ] [ 0 ] , self . value [ i ] [ 0 ] [ 1 ] , self . impurity [ i ] ) for i in range ( 0 , self . node_count ) if ( self . is_leaf [ i ] ) ] index , leaf_samples_0 , leaf_samples_1 , impurity_sample = zip ( * leaf_samples ) if leaf_sample_size is None : leaf_sample_size = len ( index ) if figsize : plt . figure ( figsize = figsize ) p0 = plt . bar ( range ( 0 , len ( index [ : leaf_sample_size ] ) ) , leaf_samples_0 [ : leaf_sample_size ] ) p1 = plt . bar ( range ( 0 , len ( index [ : leaf_sample_size ] ) ) , leaf_samples_1 [ : leaf_sample_size ] , bottom = leaf_samples_0 [ : leaf_sample_size ] ) plt . xticks ( range ( 0 , len ( index ) ) , index ) if plot_ylim is not None : plt . ylim ( 0 , plot_ylim ) plt . xlabel ( "leaf node ids" , size = 20 ) plt . ylabel ( "samples" , size = 20 ) plt . grid ( ) plt . legend ( ( p0 [ 0 ] , p1 [ 0 ] ) , ( 'class 0 samples' , 'class 1 samples' ) )
Show samples by class for each leaf.
Show samples by class for each leaf .
"""Show samples by class for each leaf.

    :param plot_ylim: int, optional
        The max value for oY. This is useful in case we have few leaves with big sample values which 'shadow'
        the other leaves values
    :param leaf_sample_size: int, optional
        The sample of leaves to plot. This is useful when the tree contains to many leaves and cannot be displayed
        clear in a plot.
    :param figsize: tuple of int, optional
        The plot size
    """
self
figsize
tuple of int, optional
The plot size
tuple of int optional The plot size
leaf_sample_size
int, optional
The sample of leaves to plot. This is useful when the tree contains to many leaves and cannot be displayed
clear in a plot.
int optional The sample of leaves to plot . This is useful when the tree contains to many leaves and cannot be displayed clear in a plot .
plot_ylim
int, optional
The max value for oY. This is useful in case we have few leaves with big sample values which 'shadow'
the other leaves values
int optional The max value for oY . This is useful in case we have few leaves with big sample values which ' shadow ' the other leaves values