In-class programming—Altair interactive
Due 2023-10-06, 11:59pm EST 3pts 40minPlease 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
- Instructions
- Submission instructions
- Grading
- Tips, tricks, and troubleshooting
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
-
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.
-
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>
CD
or open a terminal / command prompt window into the cloned folder.-
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
orwhere.exe python
—the first one listed should be inside theenv
folder you just created. -
-
Install necessary packages.
python -m pip install -r requirements.txt
This may take a few minutes.
Run Jupyter Lab and create a notebook
- Run
python -m jupyter lab
. It should open Jupyter Lab in your default browser. - Create a new Jupyter Notebook named
interactive-vega-altair.ipynb
. - 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
- 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
- Make sure to save your .ipynb file and shutdown Jupyter Lab properly through the file menu. Otherwise, you need to use
jupyter notebook stop
. - Deactivate the venv to return to your terminal using
deactivate
.
Commit and push your code (but first…)
-
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
-
Make sure to add all your required files, including the
.ipynb
file and any images to the git repo. -
Finally, commit all your local files and push them to the remote repository on GitHub.
Submission instructions
- 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: