Wrap-up, Outlook, Jupyter and Quarto

Statistical Programming
Prof. Dr. Martin Spindler

It’s a wrap!


Congratulations


🥳 You’ve learned how to program with Python! 🎉

What’s next?

What’s next?

Statistics, Causal ML

What’s next?

  • Learn more tools / skills
    • Git / GitHub
    • Data Products with Quarto
    • More of the Python Ecosystem

Notebooks & Publication Systems

Notebooks and Publication Systems

  • Jupyter and Quarto are two frameworks to combine data and code in a single document

    • Jupyter is a notebook framework that is based on Python
    • Quarto is a framework that is based on markdown and can be used with Python, R, julia, etc.
  • Both frameworks are based on markdown and allow to combine code and data in a single document

  • You can use them to create reports, blogposts, websites, slideshows, etc.

  • You can load data, run code, and display (& polish) results in the same document

Jupyter

  • Installation guidelines & getting started guide
  • Open Jupyter Notebook and create a new notebook (.ipynb file)
    • Open Anaconda Navigator and launch Jupyter Notebook
    • Create a new notebook
    • Run some code (e.g., from lecture or problem set)
  • Alternatively, you can use VS Studio Code
    • Open Anaconda Navigator and create a new .ipynb file
    • Create a new notebook
    • Run some code (e.g., from lecture or problem set)

Jupyter

  • A Jupyter notebook has two types of cells:
    • code cells, and
    • markdown cells
  • Markdown cells allow you to write text and format it using markdown syntax
  • Code cells allow you to write and run code
    • You have to specify the a kernel for the programming language in the top right corner

Jupyter

  • Jupyter is very popular and it easily integrates with cloud services/servers

  • Very convient: google Colab!

    • You can run notebooks in the cloud (e.g., on Google servers)
    • You can share notebooks with others
    • You can run notebooks on GPUs (e.g., for deep learning)
  • There are various extensions available, see https://docs.jupyter.org/en/latest/

    • For example nbconvert to convert notebooks to other formats (e.g., html, pdf, etc.)

Quarto

  • Quarto is a relatively new framework to generate dynamic content, like

    • (Automated) Reports that involve Python, R, julia or other code
    • Blogposts, websites, pdf files, slideshow, jupyter notebooks, interactive apps, MS office documents
    • Documents including references (e.g. .bib files) and math formula (LaTeX)
  • Thereby, Quarto has a unified syntax that is based on markdown

  • Installation guidelines & getting started guide

Quarto

  • Open new .qmd file and render
    • Render using the VS Studio features (Ctrl + k) or command line quarto render
  • Go through the Quarto Guide to find out more
    • Topics: Basic syntax, computations, document types, output type (tables, figures, etc.)

Quarto

  • It is very easy to get started with Quarto

  • You can use Quarto in combination with GitHub, for example to set up your personal website

  • Quarto is developing very fast, for example recently they added support for dashboards

Quarto: PDF files

  • Create a new .qmd file and render it as .pdf
    • Header option format: pdf
    • You can source a .bib file and use LaTeX syntax to cite references
    • You can also use a .tex preamble and commands to customize the document
    • You can use the quarto render command in the terminal
    • You can also use the VS Studio features (Ctrl + k) to render the file
  • You can also output .docx files etc.

Quarto: Presentations

  • With reveal.js, slideshows become interactive, for example, you can include GIFs, videos, animations, etc.

  • reveal.js: Create a new .qmd file and render it as .html slideshow

    • Header option format: revealjs

Literature

References

References

Chernozhukov, Victor, Christian Hansen, Nathan Kallus, Martin Spindler, and Vasilis Syrgkanis. 2024. “Applied Causal Inference Powered by ML and AI.” https://arxiv.org/abs/2403.02467.
Cunningham, Scott. 2021. Causal Inference: The Mixtape. Yale university press.
Facure, Matheus. 2023. Causal Inference in Python. O’Reilly Media, Inc.
Huber, Martin. 2023. Causal Analysis: Impact Evaluation and Causal Machine Learning with Applications in r. MIT Press.