# When a Zombie is Your Neighbor ๐ŸงŸ: KNN in the Zombie Apocalypse ## EAAI Activity Presentation by Yim Register (They/Them) & Dan Schneider (He/Him) #### ๐Ÿ’ก This lesson is designed for a middle-school audience and assumes no prior experience with A.I. and machine learning --- *The zombies have taken over. At first it was slow, a few cases here or there. Now they're spread through our entire town! We need to safely get around town, but don't know where the zombies tend to congregate. However, we got reports on our radio from the neighboring town about where the zombies tend to gather.* **Using their data, can we predict how many zombies will be at different locations in our town and pick the safest place to hide?** ![](https://i.imgur.com/4G7loqb.png) --- ## Welcome to Our Town <center> <img src="https://i.imgur.com/Y0E8w0N.jpg" width=500x alt="map"></img> </center> This is our town and this is our survival map! Make sure to keep notes with your predictions and observations! --- ## Data From the Neighboring Town <center> <img src="https://i.imgur.com/QlRdyHg.jpg" width=150x alt="radio"></img> </center> This is the data from the next town over that they transmitted on the radio. First they recorded information about locations around town. For each location, they also recorded if it was Indoor or Outdoor **(Building)**, the kind of building it was **(Type)**, how loud it was **(Noise Level)**, and whether or not it had a **(Sidewalk)**. Next, they counted how many zombies **(ZOMBIES :zombie:)** were at each of the locations! ![](https://i.imgur.com/VKFBdyV.png) --- ## What do you notice? Time for your field notes! ![](https://i.imgur.com/K3ZELID.png) --- ## Let's make a prediction We've looked at the data and tried to pick out patterns. Now we are going to try to make a prediction. Using information we already know, we will try to estimate the number of zombies in a new location. ![](https://i.imgur.com/bzq6JBD.png) --- Here's the location we want to make a prediction for: * It's an **indoor** building. * It's a **restaurant**. * The noise level is **low**. * It has **no sidewalk**. How many **ZOMBIES :zombie:** do you think there will be? ![](https://i.imgur.com/Kp07MBs.png) --- ## Count the Similarities We will count up the number of similarities that Location A has with each of the locations in our data. ![](https://i.imgur.com/4k06wuq.png) ![](https://i.imgur.com/0or7qFH.png) --- ## Count the Similarities: Answers Here is that chart all filled in. Our indoor restaurant with low noise and no sidewalk shares these similarities with the data we already have: ![](https://i.imgur.com/T0GO99G.png) Once you count up all the similarities, this is what you'll have: ![](https://i.imgur.com/vdqtSUC.png) --- ## Top 3 Similar Locations Which 3 locations share the most similarities to our Location A? Top 2? Top 4? This is *k* of *k-nearest neighbors*. ![](https://i.imgur.com/U4zGNah.png) --- ## The Calculation <span style="color:orange"> (**ZOMBIES:zombie:** at Location 3</span> + <span style="color:orange"> **ZOMBIES:zombie:** at Location 4 </span> + <span style="color:orange"> **ZOMBIES:zombie:** at Location 5) </span> รท *k* = <span style="color:green">Predicted **ZOMBIES:zombie:**</span> <span style="color:orange"> (9 </span> + <span style="color:orange"> 45 </span> + <span style="color:orange"> 21) </span> รท *3* = <span style="color:green">Predicted **ZOMBIES:zombie:**</span> (75) รท *3* = <span style="color:green">25:zombie:</span> ![](https://i.imgur.com/KXOK77r.png) Students do this for multiple locations on the map, and try to determine the safest place to hide! They can discuss how results might change if they used the top 2 similar locations, or the top 4. --- ## Accuracy You managed to escape the zombie outbreak and find help. You're also able to survey your town and see how many zombies were *actually* wandering around the town. Here is the data comparing the predicted number of zombies with the actual number of zombies: *(Students fill out this chart)* ![](https://i.imgur.com/07x2jVq.png) Other teams were also trying to predict how many zombies were in their towns. Using the data below, calculate the accuracy in three different ways: exact matches, within 5, and within 20. *(Students fill out this chart)* ![](https://i.imgur.com/BEnsvem.png) --- ## Will we have an Exact Match? ![](https://i.imgur.com/JlmQI0s.png) --- ## Remember the Situation ![](https://i.imgur.com/ZG8LkiQ.png) --- ## AI Accuracy in the Real World <center> <img src="https://i.imgur.com/Lyu5do3.jpg" width=100x alt="medical"></img> </center> ![](https://i.imgur.com/SCEwMLR.png) --- ### Medical <center> <img src="https://i.imgur.com/Op3s8tK.png" width=100x alt="medical"></img> </center><br> AI is used to help diagnose illnesses, distribute medical resources, predict outbreaks, and calculate insurance payments. ***Discuss:*** Should we be relying on AI for problems like these? What factors should we consider before trusting an AI model in these scenarios? --- ### Law <center> <img src="https://i.imgur.com/BpUnxhI.jpg" width=150x alt="law"></img> </center> AI is also used in the criminal justice system. It can be used to distribute police officers to specific locations, calculate someone's risk of committing a crime, or even use facial recognition to decide if someone is a criminal. These models are often flawed and built on the wrong assumptions. ***Discuss:*** How should we determine "close enough" accuracy for problems like these? How can we speak kindly about the people that AI models will affect? --- ## Lesson Resources - [Model AI Page](http://modelai.gettysburg.edu/2022/zombie/) - Lesson Plan - [Static PDF for Model AI](http://modelai.gettysburg.edu/2022/zombie/Lesson_Plan.pdf) - [Full Lesson Plan](https://studio.code.org/s/aiml-2021/lessons/11) - [Slides](http://modelai.gettysburg.edu/2022/zombie/Slides.pdf) - [Zombie Map](http://modelai.gettysburg.edu/2022/zombie/ZombieMap.pdf) - [Activity Guide - Zombie Prediction](http://modelai.gettysburg.edu/2022/zombie/Activity_Guide_Zombie_Prediction.pdf) - [Activity Guide - Zombie Accuracy](http://modelai.gettysburg.edu/2022/zombie/Activity_Guide_Numerical_Accuracy.pdf) - [Key - Zombie Prediction](http://modelai.gettysburg.edu/2022/zombie/Key_Zombie_Prediction) - [Key - Zombie Accuracy](http://modelai.gettysburg.edu/2022/zombie/Key_Numerical_Accuracy.pdf)