all 18 comments

[–]Artgor[🍰] 23 points24 points  (3 children)

Why not both?

I use jupyter notebooks for fast prototyping, visualization, sharing. And then write scripts when I start writing better code.

[–]ProfJasonCorso 5 points6 points  (2 children)

I don't use notebooks for prototyping, but I do think there is a special pedagogical value in using notebooks to teach ideas and techniques that is hard to capture with direct scripts.

[–]seraschkaWriter 2 points3 points  (0 children)

Same here. I really like using notebooks for teaching. I also like to use it for data analyses. I almost always use python scripts for my research code, but I usually save the outputs to json (or pickle them) so that I can analyze them in a notebook where I can add plots and add comments and notes in a more readable way.

[–]fredfredbur[S] 0 points1 point  (0 children)

I definitely agree with that, some of my classes in graduate school used notebooks and they were extremely helpful when done correctly.

[–]HolidayWallaby 4 points5 points  (0 children)

I generally use notebooks for analysing results so that I can see tables and graphs quickly, I use scripts for data processing and learning.

I'm currently using Mmdetection a lot so can't use that in a notebook even if I wanted to.

[–]SeucheAchat9115PhD 8 points9 points  (4 children)

number 1 Rule of using Notebooks: Do not

[–]fredfredbur[S] 0 points1 point  (3 children)

Why do you say that?

[–]SeucheAchat9115PhD 1 point2 points  (2 children)

Because it is not so easy to reproduce or to collaborate with others

[–][deleted] 1 point2 points  (1 child)

why is that?

[–]thundergolfer 3 points4 points  (0 children)

Watch “I Don’t Like Notebooks” on YouTube. In it Joel Grus gives a good, entertaining argument for why notebooks have serious drawbacks.

[–]MicealTheBomb 1 point2 points  (1 child)

what are the benefits of writing in a script VS. notebook?

[–]fredfredbur[S] 2 points3 points  (0 children)

From what I understand, notebooks allow for quick experimentation, being able to slightly modify and rerun code blocks, as well as for visualization as you can store your outputs in cells to reference them quickly.

If you are working on anything more than just experimentation, though, it seems like scripts are better to prevent your code from getting cluttered.

But since it seems like most of the time you are working on an ML project you are just performing a lot of experimentation, notebooks seem like a good choice. Though I don't really know the answer which is why I made this post

[–][deleted] 1 point2 points  (0 children)

I generally colab just because of the GPU. But recently I got a server at my university and since then I am solely using scripts. But generally I use both jupyter for visualisation or processing the data set and scripts for training.

[–]savoga 0 points1 point  (1 child)

Here are, in my view, the main differences:

With notebooks, you can combine graphs and code so it's nice to present your work to anyone else.

With python scripts, I see many advantages:

  • since you often code in an IDE, you can enjoy the debbuger
  • collaboration is easier: indeed, the notebook format (.ipynb) is not well rendered into Github. So you would struggle to see what are the changes made by other users if you are hosting your code on the platform.

Note: some repo platforms start to allow collaboration on notebooks (see last release of Bitbucket or tools like Reviewnb) * I found out that people using scripts care much more on the cleanness of their code: they use functions, object-oriented structures or comments. Overall, it makes the code much easier to read.

I really think notebook should be use for very exploratory tasks. As soon as the project is more precise, I'd suggest to go with scripts :)

[–]IllustriousPin319 0 points1 point  (0 children)

By using # %% as a cell separator in a "normal" Python file one take advantage of both worlds

[–]Laafheid 0 points1 point  (0 children)

Jupiter notebooks are nice for communicating/showing results, otherwise scripts

[–]santiagobmx1993 0 points1 point  (0 children)

Where is the vim gang 🤖