Penguin Forest
In this unit you fit a random forest to the Palmer penguins data. The forest predicts how long a penguin’s bill is. Then you make a chart of the feature importance. Feature importance shows which columns help the model most. The lecture is a notebook. Open it and follow along in class. Then you do an exercise with hotel bookings data, push it to your fork, and turn in the link.
The two notebooks come from another class, so you copy them into your fork with your AI assistant.
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
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.2. Get the notebooks
The notebooks are in the DATA 730 lecture repo, not in the class repo. Paste this prompt into opencode. It downloads the lecture into your notebooks folder and the exercise into your exercises folder.
Copy two notebooks from another class into my fork.
1. Download these two files with curl and save them at the paths below:
https://raw.githubusercontent.com/UNC-DATA-730/lecture-notebooks/main/10-decision-trees/lectures/00_random-forest-tidymodels.ipynb
-> notebooks/15-lecture-penguin-forest.ipynb
https://raw.githubusercontent.com/UNC-DATA-730/lecture-notebooks/main/10-decision-trees/in-class-exercises/hotel-bookings-model.ipynb
-> exercises/15-hotel-bookings-exercise.ipynb
If a file already exists at a path, skip that file and tell me. Do not overwrite it.
2. Check that each file is a notebook and not an error page. It must start with "{" and
have a "cells" key. If not, stop and tell me what you got.
3. Clear all outputs in each new file with this command:
pixi run jupyter nbconvert --clear-output --inplace <path>
4. Do not change the code in the notebooks. Do not commit yet.
5. Show me the paths of the new files.When it is done, check that the notebooks arrived:
ls notebooks exercisesYou should see notebooks/15-lecture-penguin-forest.ipynb and exercises/15-hotel-bookings-exercise.ipynb.
3. Install the packages
The notebooks need four R packages:
r-palmerpenguinshas the penguin data.r-rangerfits random forests.r-rpart.plotdraws a decision tree.r-vipmakes the feature importance chart.
You may have some of them from the last two units. It is OK to add them again. Run:
pixi add r-palmerpenguins r-ranger r-rpart.plot r-vipWait for the prompt to come back. If it fails, run pixi install, then try again. If it still fails, tell the instructor.
4. Start JupyterLab
Open a second terminal with the + button in the terminal panel. Then run:
pixi shelljupyter lab --ip=0.0.0.0 --port=8888 --no-browser --IdentityProvider.token='' --ServerApp.password='' --config=jupyter_config.pyIf you added the jlab task in the Model Basics unit, you can run this one command instead:
pixi run jlabOpen 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.

If a cell says a package is not installed, stop JupyterLab, do step 3 again, and start it again.
5. Follow along with the lecture
In JupyterLab, double-click the notebooks folder, then 15-lecture-penguin-forest.ipynb. Follow along in class. You do not need to change it or turn it in.
6. Complete the exercise
Double-click the exercises folder, then 15-hotel-bookings-exercise.ipynb. Fill in the empty cells in order. Use opencode when you need help.
The exercise reads the hotel data from the internet. You do not need to upload a file.
Save your work.
7. 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 packages.
Help me turn in exercises/15-hotel-bookings-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/15-hotel-bookings-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/15-hotel-bookings-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
-newfile, the class version of that notebook changed. Open it next to your own copy to see what changed. - Next time you open the Codespace,
palmerpenguinsis still there.