Link Search Menu Expand Document

In-class programming—Altair

Due T 2022-02-15, 11:59pm EST 2pts 30 min

Please ask any questions about this assignment in class, or later today on Canvas in Discussion: In-class programming—Altair.

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

Table of contents

Change log

  • N/A.

Aim of the assignment

Altair is a declarative statistical visualization library for Python, based on Vega and Vega-Lite. In this tutorial you will learn how to use Jupyter Lab and Altair.

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/17WY0Irw

    For reference, this is the template repository your repository is being created from: https://github.com/NEU-DS-4200-S22/In-Class_Programming--Altair.

    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.

     pip install -r requirements-noversions.txt
    

    This may take a few minutes.

    Note that we also include requirements.txt which pins the exact versions of the packages we used at the time of assignment creation. You are welcome to use that instead in case library changes have made the assignment problematic.

Run Jupyter Lab and create a notebook

  1. Run jupyter lab. It should open Jupyter Lab in your default browser.
  2. Create a new Jupyter Notebook named south_end.ipynb.
  3. Follow along with the in-class tutorial. Once you have written code in a cell you can run it with ctrl+enter. In the menu you can run all cells and restart the kernel to clear variables. If you get lost, you can look at south_end_complete.ipynb.

    Note: You do not need to also do the infographic creation in Adobe Illustrator. That part of the tutorial is just to give you an idea of what is possible.

When we are done with the tutorial, if you have time…

  1. Start working through the Altair data visualization curriculum.

At the end of the exercise…

Clear your output

  1. Before you commit a Jupyter Notebook .ipynb file, you should clear the outputs of all cells. 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.

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:

    1. You cleared all cell outputs.
    2. All of your required files including south_end.ipynb are 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.
  2. Submit the URL of your repository to the assignment In-class programming—Altair in GradeScope.

    Warning: Do not put a link to a personal repository. It must be within our class GitHub organization.

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

CriteriaPoints
Satisfactory?2

Tips, tricks, & troubleshooting

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


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