Dengue Forecasting

In this unit you forecast dengue cases. To forecast is to predict a number for future weeks. You use weekly weather data from two cities, San Juan and Iquitos. You fit a random forest, then add lag features and see if the forecast gets better. A lag feature is a value from past weeks, like the number of cases last week. You do the exercise with your AI assistant, push it to your fork, and turn in the link.

You need your fork of the class repo, the pixi environment from the Random Forests unit, and opencode from the AI Pairing unit.

1. Sync your fork

The exercise is in the class repo, not in your fork yet. Open your Codespace from github.com/codespaces. In the terminal, run opencode and paste this prompt:

Sync my Codespace with the class repo and push my work. Do not lose any of my work.

1. Run git status. If there are any changed or new files, stage them all and commit
   with the message "save my work before sync".
2. Run gh repo sync. If it succeeds, go to step 6.
3. If it fails because of diverging changes, do NOT run it again with --force. Instead,
   run git fetch upstream, then merge upstream/main into my current branch. If there
   is no remote named upstream, stop and tell me.
4. If a notebook (.ipynb) in notebooks/ or exercises/ has a conflict, do not edit inside the file. Keep my version
   under the original name. Save the class version next to it with "-new" added
   before .ipynb. Then mark the conflict resolved.
5. Commit the merge.
6. Push to origin.
7. Show me a short list: files that came in from the class repo, and any "-new" files
   you made. Stop after that. Do not delete anything. Do not force push.

When it is done, check that the exercise arrived:

ls exercises

You should see exercises/14-dengue-exercise.ipynb.

2. Install vip

This unit needs one new R package. r-vip makes a chart of the features that matter most to a model. Add it to your pixi environment:

pixi add r-vip

Wait for the prompt to come back. If it fails, run pixi install, then try again. If it still fails, tell the instructor.

The exercise also uses ranger from the Random Forests unit. If you did not add it, run pixi add r-ranger too.

3. Get the data

The data is on Canvas, not in the class repo. Download these two files to your computer:

Then upload them to your Codespace:

  1. In VS Code, click the Explorer icon on the left bar.
  2. Right-click the empty space below the files. Choose New Folder… and name it data. The data folder must be at the top level, next to exercises and notebooks.
  3. Right-click the data folder and choose Upload….
  4. Select the two CSV files and click Open.

Check that the files arrived:

ls data

You should see dengue_features_train.csv and dengue_labels_train.csv.

You do not turn in the data. Do not commit it.

4. Start JupyterLab

Open a second terminal with the + button in the terminal panel. Then run:

pixi shell
jupyter lab --ip=0.0.0.0 --port=8888 --no-browser --IdentityProvider.token='' --ServerApp.password='' --config=jupyter_config.py

If you added the jlab task in the Model Basics unit, you can run this one command instead:

pixi run jlab

Open JupyterLab the same way as before. Click the Ports tab, find the 8888 row, and click the globe icon. Do not use the Open in Browser popup.

The Ports tab in VS Code. The row for port 8888 is highlighted and the globe icon shows a tooltip that says Open in Browser.

Hover over the 8888 row and click the globe.

If a cell says vip or ranger is not installed, stop JupyterLab, do step 2 again, and start it again. If a cell cannot find a CSV file, do step 3 again.

5. Complete the exercise

In JupyterLab, double-click the exercises folder, then 14-dengue-exercise.ipynb. Do the steps in order. Use opencode when you need help.

Save your work.

6. Submit the exercise

Paste this prompt into opencode. It pushes the exercise to your fork and gives you the link. It also pushes pixi.toml and pixi.lock, so your fork remembers the new package. It does not push the data.

Help me turn in exercises/14-dengue-exercise.ipynb.

1. Check that the notebook file exists and has saved outputs. If the cells have no
   outputs, stop and tell me to run all cells and save with Ctrl+S.
2. Run git status. Stage the notebook. If pixi.toml or pixi.lock changed, stage them too.
   Do not stage anything else.
3. Commit with the message "complete exercises/14-dengue-exercise.ipynb".
4. Push to origin. If the push is rejected, stop and tell me. Do not force push.
5. Print the link to the notebook on my fork on GitHub. It looks like
   https://github.com/<my-username>/codespace/blob/main/exercises/14-dengue-exercise.ipynb
   Get my username from the origin remote.

Open the link. Check that GitHub shows the notebook with its outputs. Then paste the link into the Canvas assignment.

Things to know

  • Stop your Codespace when you are done to save your free hours.
  • If the sync makes a -new file, the class version of that notebook changed. Open it next to your own copy to see what changed.
  • Next time you open the Codespace, the data folder and vip are still there.