<jupyter_start><jupyter_text>Useful modules in jupyter notebook- This notebook includes some basic tools in notebook  change module path, file path- add your module path (different from where the notebook is)- change your base path<jupyter_code>import os
import sys
# add your module path
module_path = os.path.abspath(os.path.join('..')) # '.'
if module_path not in sys.path:
    sys.path.append(module_path)
# change your base path
os.chdir('./') # '../'
print(os.getcwd())<jupyter_output>/Users/ericjau/Documents/eric-yyjau.github.io/misc/jupyter_notebook<jupyter_text>auto-reload- when you change anything in python files, the notebook will reload automatically.<jupyter_code>%load_ext autoreload
%autoreload 2<jupyter_output><empty_output><jupyter_text>Display- fit your notebook as wide as the browser<jupyter_code>from IPython.core.display import display, HTML
display(HTML("<style>.container { width:100% !important; }</style>"))<jupyter_output><empty_output><jupyter_text>Others<jupyter_code>import numpy as np
import matplotlib.pyplot as plt<jupyter_output><empty_output><jupyter_text>Debug with python file<jupyter_code># import function and run
from utils import print_words
words = {'ucsd': 'ece', 'ntu': 'ee'}
print_words(words)
# import function and visualize
from utils import get_rand_img
img = get_rand_img(20, 30)
plt.imshow(img)
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11159107271418287, 'fraction_numerical': 0.005759539236861051, 'mean_word_length': 6.853107344632768, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '585966', 'license': 'CC-BY-3.0', 'n_tokens_mistral': 478, 'n_tokens_neox': 463, 'n_words': 121, 'path': 'misc/jupyter_notebook/useful_modules.ipynb', 'repo_name': 'eric-yyjau/eric-yyjau.github.io', 'size': '1389'}