I won’t be having regularly scheduled office hours this week at the usual times, but if you need a face-to-face, we can set that up over email. Most convenient for me is tomorrow (Tuesday) afternoon, from say noon-4pm, during which I will, in fact, physically be in Farmer. If you drop on by at that time, no need to set up anything special.
-
Office hours during finals week
-
About the final exam
If you haven’t already physically handed me your XP cards, you can simply bring them to the final exam and staple them to it. (If you’re not planning on taking the final, email me and we’ll work something out about your XP cards.)
As for what the final will cover, everything we’ve learned this semester is fair game, including Silver. The exam will be open most things (open notes, handouts, previous quizzes, examples from the course website, Mesa and Networkx APIs, the Silver book itself) but closed Python. Lastly, the exam will itself be at the schedule time as listed in the syllabus: Thu May 2nd, 3:30-6pm. Bring a pencil, as well as your laptop if you’d like to consult any of the aforementioned items.
-
The “My XP” tab
It’s easy to overlook, but there is a tab labeled “My XP” on the scoreboard which will allow you to see an exhaustive list of all the XP you’ve gotten this semester, for all the different assignments. Please do look at that to verify nothing from you slipped through the grading cracks.
-
Quiz #6 (and last) posted!
As promised, the last quiz of the semester has been posted, and isn’t due until the end of finals week. Good luck!
-
Last class canceled
I hate to have to do this, but it looks like I’m not going to be able to make it to campus at all tomorrow due to a last-minute kerfuffle. It’s especially a bummer since it was our last scheduled time to meet and now the Granovetter model kind of ends on an anticlimax.
As partial recompense, I offer to you the following extra credit activity: download our Granovetter code from last class, and run it on your system several times. Observe how the percentage of rebels changes over time, and more importantly, how the eventual percentage of rebellious people changes from run to run.
Update the code and produce (1) several (we’ll say several == 5) time series plots of the percentage of rioters over time, for different runs of the simulation, and (2) a plot of a parameter sweep showing the total number of agents (N) versus the final percentage of rioters. (To avoid complexity, you can use a fixed number for “final” percentage — for example, run every simulation for 20 steps, and then just compute the percentage of rioters at the end of those steps. I won’t make you write code to detect the point when there are no additional rebels and stop there.)
Does your parameter sweep align with your intuition? It doesn’t mine! I find the results of this model, and the conclusions from the parameter sweep, puzzling indeed.
To claim these XP (I’ll award up to +15XP for it) send me (where “me” == stephen_at_UMW) your six plots as attachments to an email with subject line “DATA 420 last class activity” no later than next Monday at midnight. In the body of the email, write one paragraph describing the takeaways from your plots and what you learned from the Granovetter model.
-
Extra credit opportunities
You can earn:
- +1XP for each additional interesting modification (not mentioned in class) to the Binary Voter Model you can come up with which would prevent eternal uniformity. To claim these point(s), send me (stephen_AT_umw) an email with subject line “DATA 420 BVM extension ideas” and with each such idea expressed in a short, understandable paragraph. (Limit five.)
- +5XP for attending Harmony’s honors defense in Farmer 036 at 1-1:30pm Friday Apr 26, and writing a one-paragraph summary and one-paragraph response to and critique of her project. To claim these points, send me (stephen_AT_umw) an email with subject line “DATA 420 Harmony honors thesis reflection” by Monday at midnight.
-
Office hours truncated today
Today my office hours will only be from 3:15-4pm, as I have an honors defense I need to attend.
-
Graph and BVM code examples posted
to the class repo, in the usual place.
-
Last homework posted!
The last homework of the semester has been posted, and is due at the stroke of midnight before Finals Week commences. Good luck!
-
Quiz 5
For questions 8 and 9 on the quiz, use a Moore neighborhood. Also, always (on all questions) assume “torus” is OFF.
-
Quiz #5 posted!
It’s due on April 18th, and covers no material later than last week.
-
Reflection paper #2 posted!
It is due the last day of class. Be creative, be insightful, and challenge yourself to deeper thinking!
-
Trend detectors graded
To test your trend detector, I did the following:
- Give you +2XP for turning it in, no matter what.
- Change the name of your turnin file to “yourfirstname_trend_detector.py“, and change the import line at the top of my test script to match.
- Run my test script against it. This tests nine sequences: three rising ones (red), three falling ones (blue), two steady ones (green), and my weight (black). You got one point for each of the first eight you got correct. I thought about giving an extra point to those who said my weight was FALLING, just because it made me feel good, but decided against it.
For those keeping score: out of the 10 students who turned this in, five of their algorithms said my weight was FALLING, four said STEADY, and one said RISING. (I have already spoken harsh words to this last person.)
-
Trend detector
For up to +10XP, create a function called trend_detector() which accepts a 1-dimensional NumPy array of floating-point/decimal/double numbers (of any length), and returns one of the three string values "UPWARD", "DOWNWARD", or "STEADY". These should correspond to whether you think the numbers are showing an upward trend (like we fear global temperatures are), or a downward trend (like we hope Stephen’s weight is), or a steady-as-she-goes trend.
There’s no one right or wrong answer to this. I will judge it based on my own discretion. I’ll feed it some sequences which seem to me obvious upward trends, obvious downward trends, and obvious steady-as-she-goes trends, and see whether yours agrees with my assessment. I’ll also look at it for cleverness, elegance, and complexity.
To claim these points, email me (not data420@, but me personally) your function as a single standalone .py file no later than midnight, April 12th. The function should be called exactly trend_detector() and should function exactly as described above. Any deviations from these instructions will cost you points.
-
Miscalibration
This semester has progressed more slowly than I’ve anticipated, in terms of the amount of material we’ve covered and the amount of project work I’ve assigned. We aren’t going to have seven programming assignments, as it says in the syllabus: only five. And we aren’t going to have eight quizzes, as it says in the syllabus: only six. Hence I’m giving everyone the “missing experience points” needed to catch up to reality today.
-
Plotting your legend off the grid
Kenzie figured out that if you add “bbox_to_anchor=(1,1)” as an argument to your plt.legend() call, it will helpfully plot the legend to the upper-right, and outside the plotting area used for the grid.
-
heatmap ranges (“my agent colors are inconsistent”)
If you’re using sns.heatmap() to draw your animation, and you have colors mapped to integer values (like no-agent-here = 0, susceptible = 1, infected = 2, recovered = 3), be sure to set the range to fixed values via the vmin and vmax arguments. In this case, you would want to set vmin=0 and vmax=3 so that in every frame of the animation, the heatmap assigns the same colors to the same values rather than re-calibrating each time.
-
Plotting a “groupby”
For those who haven’t used Pandas… let’s say you have a DataFrame called df with columns myIndepVar and myDepVar. If you want to average all the myDepVar values for each distinct value of myIndepVar, and plot that, here’s one way you could do that:
grouped = df.groupby('myIndepVar').myDepVar.mean() plt.plot(grouped.index, grouped.values)
-
Class -> office hours today
A lot of people were struggling getting their SIR ABM simulations running (and the animation appearing) in office hours today. So I think for today we’ll cancel normal class and just devote that time to office hours. I’ll start out in the classroom at the normal time, to make sure there’s enough seats (yesterday not everyone could fit in my office) and migrate to my office when the crowd dies down enough to make it possible.
-
Another office hours switch
I need to move my office hours for tomorrow (Thu Apr 4) to 3:30-4:30pm instead of their regularly scheduled 11-2pm. I apologize for any inconvenience.
-
I also want this plot
I guess I didn’t say this anywhere in the assignment (will fix now) but as part of your “basics” stuff for part 1, I want to see your time plot of S’s, I’s, and R’s. You’ll recall it looked something like this for the “perfect” SD model:
For the agent-based model, you should get the same phenomenon, but of course the curves won’t be as “pristine” because you have a finite number of individual agents who are interacting randomly. Depending on your RNG and what your parameter settings are, you might get something like:
-
“freeze support”
Some people are getting “freeze support” error messages when they try to do batch runs for the ABM II homework. I have little idea what this means, but the following fix was discovered that at least worked for two people:
In your code, first import:
from multiprocessing import freeze_support
Then, before you call batch_run(), put this code:
if __name__ == "__main__": freeze_support() ...the rest of your code goes indented under here...
So the call to batch_run() and everything after it goes into an if statement with the above crazy condition on it. Try this to fix your freeze errors, and if that doesn’t make things work, send me email.
-
Office hours switch
I need to move my office hours for tomorrow (Wed Apr 3) to 4-5pm instead of their regularly scheduled 10-11am. I apologize for any inconvenience.
-
Quiz #4 posted!
Quiz #4 is posted, and is due Sunday April 7th at midnight. Unlike some of the previous quizzes, this one is closed-Python. It is timed at 45 minutes.
-
from the horse’s mouth
I asked Tom Pike (one of the core Mesa developers and a great guy) whether it was safe to blow through the ugly “the AgentSet is experimental” warnings that Mesa is giving some folks. He said:
“Yes you can ignore it, we are just prepping to release Mesa 3.0 which will switch to agentset for agent management and break older models. One can turn off the warnings this way:
import warnings warnings.filterwarnings("ignore")
-
ABM II homework posted!
As promised, your next homework assignment has been posted, and is due a week from Friday. It contains varying levels of challenge and difficulty, depending on your wants and needs. You can turn in just the basics (part 1) for half credit; or both parts 1 and 2 for the full +40XP; and/or either of both add-on extensions for an additional +20XP each on top of that.
Have fun!
-
OH on Zoom Monday
I strained my back pretty badly this weekend, and I think I need to give it another day’s rest before I consider leaving the house or walking anywhere. So office hours tomorrow will be virtual; same Zoom link as always (see the announcements in Canvas).
-
Thursday office hours are 1-2pm for reals
There was some confusion (my fault) about when my Thursday office hours would normally be. So I hereby do solemnly state for the record that from now on this semester, they will be at 1-2pm. Sorry for the mixup about this!
-
So so behind
Shane told me today “hey Stephen, I didn’t see a grade for my quiz #3 on the scoreboard. Was it missed?” The answer, unfortunately, is that I haven’t added anybody’s quiz #3 yet (nor the last-day turnins for the SD II homework) because I’ve just been so swamped.
I promise I’ll get to it as soon as humanly possible. In the meantime, enjoy an extra XP as partial compensation for your long-suffering and patience.
-
Today’s code posted
I’ve posted the code from today’s class (boltzmann.py) to the class github repo for your edification and enjoyment.
-
Office hours confusion
I think I miscommunicated (and am even confused myself) about my Thursday office hours. I was in from 1-2pm today, and had a fair crowd (three students). But I just got an email from a student saying they thought I was having them at 3:30pm. I don’t even know myself anymore. :\
Anyways, I’m home now, and won’t be returning to campus until a student club meeting tonight, but I’m happy as always to help via email.
Sorry!
-
The Mesa API
Here’s a link to the Mesa API documentation, which will come in handy this semester.