People love to hate @ProjectJupyter notebooks!
They're missing out on a great communication tool.
Here's how data scientists and machine learners can
build great Jupyter Notebooks that people love to read
They're missing out on a great communication tool.
Here's how data scientists and machine learners can
build great Jupyter Notebooks that people love to read
Fix your dang code
You can make a mess in notebooks when experimenting.
All Imports into Cell 1
Extract some functions and classes
Comments.
Fix your variable names
Fix the order and outputs
Use black to standardize your code format https://github.com/drillan/jupyter-black
You can make a mess in notebooks when experimenting.
All Imports into Cell 1
Extract some functions and classes
Comments.
Fix your variable names
Fix the order and outputs
Use black to standardize your code format https://github.com/drillan/jupyter-black
Jupyter has Markdown Cells!
Use them.
If you're not using Markdown in your Notebooks, you should not be using Notebooks.
Write some prose to explain your code.
Whether analysis or model,
do yourself a favour and document it.
Here's a markdown guide: https://www.markdownguide.org/getting-started/
Use them.
If you're not using Markdown in your Notebooks, you should not be using Notebooks.
Write some prose to explain your code.
Whether analysis or model,
do yourself a favour and document it.
Here's a markdown guide: https://www.markdownguide.org/getting-started/
Final checks
We all do it.
We forget to run a cell and wonder for an embarrassing amount of time, why we have an error in the next one.
Before you share your notebook:
Restart Kernel to forget all variables
Run All Cells
Not by hand. Automatic.
It'll show any mix-ups
We all do it.
We forget to run a cell and wonder for an embarrassing amount of time, why we have an error in the next one.
Before you share your notebook:
Restart Kernel to forget all variables
Run All Cells
Not by hand. Automatic.
It'll show any mix-ups
If this thread was informative
make sure to follow @jesperdramsch
and share the first tweet for others to learn!
I am writing 30 threads in 30 days about
machine learning
data science
Python coding
Find them here: https://twitter.com/JesperDramsch/status/1479863422967767040
make sure to follow @jesperdramsch
and share the first tweet for others to learn!
I am writing 30 threads in 30 days about
machine learning
data science
Python coding
Find them here: https://twitter.com/JesperDramsch/status/1479863422967767040
Extra Credit
Use nbconvert to run all cells from the command line
Write a utils file with reusable functions
Learn keyboard shortcuts for efficiency
Make it interactive with ipykernel
Use nbconvert to run all cells from the command line
Write a utils file with reusable functions
Learn keyboard shortcuts for efficiency
Make it interactive with ipykernel
TL;DR
Care about code quality
Use markdown cells (More than just headings)
Make sure the notebook runs
Use extra tools to make your life easier
Care about code quality
Use markdown cells (More than just headings)
Make sure the notebook runs
Use extra tools to make your life easier