woodpecker/sklearn/randomforest/random_forest_structure_classifier.py
def show_features_importance(self, barh=False, max_feature_to_display=None, figsize=(20, 10)):
        """Visual representation of features importance for RandomForest.

        Features are ordered descending by their importance using a bar plot visualisation.

        :param max_feature_to_display: int
            Maximum number of features to display. This is useful in case we have hundreds of features and the
            plot become incomprehensible.
        :param barh: boolean
            True if we want to display feature importances into a bath plot, false otherwise
        :param figsize: tuple
            the size (x, y) of the plot (default is (20, 10))
        :return: None
        """

        feature_importances, feature_names = zip(
            *sorted(list(zip(self.rf.feature_importances_, self.features)), key=lambda tup: tup[0],
                    reverse=True))

        if max_feature_to_display is not None:
            feature_names = feature_names[:max_feature_to_display]
            feature_importances = feature_importances[:max_feature_to_display]

        plt.figure(figsize=figsize)
        if barh:
            plt.barh(feature_names, feature_importances)
        else:
            plt.bar(feature_names, feature_importances)

        plt.xlabel("feature name", fontsize=20)
        plt.ylabel("feature importance", fontsize=20)
        plt.grid()
        plt.show()
Visual representation of features importance for RandomForest.

        Features are ordered descending by their importance using a bar plot visualisation.

        :param max_feature_to_display: int
            Maximum number of features to display. This is useful in case we have hundreds of features and the
            plot become incomprehensible.
        :param barh: boolean
            True if we want to display feature importances into a bath plot, false otherwise
        :param figsize: tuple
            the size (x, y) of the plot (default is (20, 10))
        :return: None
        
Visual representation of features importance for RandomForest.
Features are ordered descending by their importance using a bar plot visualisation.
Visual representation of features importance for RandomForest . Features are ordered descending by their importance using a bar plot visualisation .
def show_features_importance(self, barh=False, max_feature_to_display=None, figsize=(20, 10)):
        feature_importances, feature_names = zip(
            *sorted(list(zip(self.rf.feature_importances_, self.features)), key=lambda tup: tup[0],
                    reverse=True))
        if max_feature_to_display is not None:
            feature_names = feature_names[:max_feature_to_display]
            feature_importances = feature_importances[:max_feature_to_display]
        plt.figure(figsize=figsize)
        if barh:
            plt.barh(feature_names, feature_importances)
        else:
            plt.bar(feature_names, feature_importances)
        plt.xlabel("feature name", fontsize=20)
        plt.ylabel("feature importance", fontsize=20)
        plt.grid()
        plt.show()
def show_features_importance ( self , barh = False , max_feature_to_display = None , figsize = ( 20 , 10 ) ) : feature_importances , feature_names = zip ( * sorted ( list ( zip ( self . rf . feature_importances_ , self . features ) ) , key = lambda tup : tup [ 0 ] , reverse = True ) ) if max_feature_to_display is not None : feature_names = feature_names [ : max_feature_to_display ] feature_importances = feature_importances [ : max_feature_to_display ] plt . figure ( figsize = figsize ) if barh : plt . barh ( feature_names , feature_importances ) else : plt . bar ( feature_names , feature_importances ) plt . xlabel ( "feature name" , fontsize = 20 ) plt . ylabel ( "feature importance" , fontsize = 20 ) plt . grid ( ) plt . show ( )
Visual representation of features importance for RandomForest.
Visual representation of features importance for RandomForest .
"""Visual representation of features importance for RandomForest.

        Features are ordered descending by their importance using a bar plot visualisation.

        :param max_feature_to_display: int
            Maximum number of features to display. This is useful in case we have hundreds of features and the
            plot become incomprehensible.
        :param barh: boolean
            True if we want to display feature importances into a bath plot, false otherwise
        :param figsize: tuple
            the size (x, y) of the plot (default is (20, 10))
        :return: None
        """
None
self
barh
boolean
True if we want to display feature importances into a bath plot, false otherwise
boolean True if we want to display feature importances into a bath plot false otherwise
max_feature_to_display
int
Maximum number of features to display. This is useful in case we have hundreds of features and the
plot become incomprehensible.
int Maximum number of features to display . This is useful in case we have hundreds of features and the plot become incomprehensible .
figsize
tuple
the size (x, y) of the plot (default is (20, 10))
tuple the size ( x y ) of the plot ( default is ( 20 10 ))