This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def show_importance(model,title,X,y,n=10,show_score=True): | |
''' | |
Display feature importance list for a decision tree or | |
random forest model, optionally displaying the accuracy score | |
model: Decision tree or random forest model | |
title: title text for plot | |
X: Independent variables | |
y: Target variables | |
n: Number of important features to show (default=10 | |
show_score: calculate accuracy score (default=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def pretty_shape(my_df,desc): | |
''' | |
Displays the shape of a pandas dataframe in a prettier format. | |
I don't know why the default display bugs me. It just does. | |
my_df: source dataframe | |
desc: Descriptive text. Go nuts. | |
''' | |
print(f'\n{desc}:') | |
display(pd.DataFrame(my_df.shape, | |
columns=['count'])\ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def big_display(my_df,rows_temp=50): | |
''' | |
Purpose: Expand the default display for Jupyter notebook output, and | |
revert to previous boring values afterward | |
Requires: df: input dataframe/Series for display | |
rows: number of rows to display (default 50) | |
Warning: Managenent is not responsible for ugly notebook output if you | |
forget to set the cell output to scroll | |
''' | |
with pd.option_context("display.min_rows", rows_temp, |