Link Search Menu Expand Document

In-class programming—Altair interactive

Due 2023-10-06, 11:59pm EST 3pts 40min

Please ask any questions about this assignment in class, or later today on Slack.

You are welcome to work with other students on this assignment.

Table of contents

Aim of the assignment

This tutorial and in-class assignment will guide you through using Vega-Altair along with Jupyter Widgets to add basic interactivity.

Instructions

If you run into problems see the tips, tricks, and troubleshooting section below.

Setup instructions

  1. Accept the GitHub Classroom assignment invitation by clicking this link to get your repository:

    https://classroom.github.com/a/qFroAUHt

    For reference, this is the template repository your repository is being created from: https://github.com/NEU-DS-4200-F23/in-class-programming-Altair-interactive.

    Recall our general instructions and policies on GitHub Classroom assignments.

  2. Clone your GitHub-Classroom-generated repository to your local machine.

    E.g., in your terminal / command prompt CD to where you want the folder for this activity to be. Then run: git clone <YOUR_REPO_URL>

  3. CD or open a terminal / command prompt window into the cloned folder.
  4. Create and activate a virtual environment for this project. You may need to modify the code you use depending on what Python you have installed and how your machine is configured. To do so, run the setup commands below.

    • On macOS or Linux, run these three commands separately in case there are errors:

        python3 -m venv env
      
        source env/bin/activate
      
        which python
      
    • On Windows, run these three commands separately in case there are errors:

        python -m venv env
      
        .\env\Scripts\activate.bat
      
        where.exe python
      

    Check the path(s) provided by which python or where.exe python—the first one listed should be inside the env folder you just created.

  5. Install necessary packages.

     python -m pip install -r requirements.txt
    

    This may take a few minutes.

Run Jupyter Lab and create a notebook

  1. Run python -m jupyter lab. It should open Jupyter Lab in your default browser.
  2. Create a new Jupyter Notebook named interactive-vega-altair.ipynb.
  3. Follow along with the in-class tutorial. If you get lost, you can look at interactive-vega-altair_complete.ipynb.

At the end of the exercise…

Optionally clear your output

  1. I used to warn folks to clear the outputs of all cells before commiting .ipynb files. This decreases file size, removes unnecessary metadata, and makes diffs easier to understand. In Jupyter Lab you can use the GUI: Edit->Clear All Outputs. But here, we’re using the jupytext package to automatically create a twin .py file you can run using normal Python! It is much easier to diff.

Quit Jupyter Lab and the virtual environment

  1. Make sure to save your .ipynb file and shutdown Jupyter Lab properly through the file menu. Otherwise, you need to use jupyter notebook stop. ​
  2. Deactivate the venv to return to your terminal using deactivate.

Commit and push your code (but first…)

  1. Only if you have made any changes to the required packages (you probably didn’t), first export a list of all installed packages and their versions:

    pip freeze > requirements.txt
    
  2. Make sure to add all your required files, including the .ipynb file and any images to the git repo.

  3. Finally, commit all your local files and push them to the remote repository on GitHub.

Submission instructions

  1. Ensure that your required file is committed and pushed to the remote repository on GitHub which was generated by GitHub Classroom. We will grade based on what is available in that repository.

Grading

This is a satisfactory grading assignment. If you followed the instructions you receive full marks and if not you receive a 0. Your submission is satisfactory if you completed the main goal part of the activity.

Criteria Points
Satisfactory? 3

Tips, tricks, and troubleshooting

If you run into trouble, first look at our relevant tutorials which have tips & tricks:


© 2023 Cody Dunne. Released under the CC BY-SA license.