Skip to content

Instantly share code, notes, and snippets.

View sauravmishra1710's full-sized avatar
👨‍💻
Learning to make the Machine Learn. AI for Medicine & Healthcare.

Saurav Mishra sauravmishra1710

👨‍💻
Learning to make the Machine Learn. AI for Medicine & Healthcare.
View GitHub Profile
@sauravmishra1710
sauravmishra1710 / DisplayBinaryTree.py
Last active May 31, 2021 06:21
Visualize a Binary Tree.
class DisplayBinaryTree:
"""
Utility class to display a binary tree.
Referrence:
https://stackoverflow.com/a/54074933/599456
"""
def __init__(self):
@sauravmishra1710
sauravmishra1710 / Highlight_Max
Last active March 17, 2020 06:37
highlight the maximum in a Series or DataFrame
************************************************************************************************************
'''highlight the maximum in a Series or DataFrame'''
# For more on dataframe styling refer - https://www.kaggle.com/nxrprime/styling-data-frames-covid-19-vs-conferences
************************************************************************************************************
def highlight_max(data, color='red'):
attr = 'background-color: {}'.format(color)
if data.ndim == 1: # Series from .apply(axis=0) or axis=1
is_max = data == data.max()
return [attr if v else '' for v in is_max]
@sauravmishra1710
sauravmishra1710 / DisplayAllImages
Created March 3, 2020 17:22
Display all images in a folder
import glob
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
%matplotlib inline
images = []
for img_path in glob.glob('./Data/1/*.png'):
images.append(mpimg.imread(img_path))
plt.figure(figsize=(20,10))
######################################################################################################
Display markdown like formtted text in notebook via code
######################################################################################################
from IPython.display import Markdown
'''Display markdown formatted output like bold, italic bold etc.'''
def formatted_text(string):
display(Markdown(string))
######################################################################################################