Day 18 Agent-Based Models - Superbugs 2¶

Nov. 17, 2020¶

CMSE logo

Announcements¶

  • Homework 5 Coming soon. Working with Tensorflow. Will be due 12/4.
  • Projects Rubric nearly complete and will be posted this week.
    • Due finals week
    • 8-10 minute video presentation + documented notebook on your analysis
    • 3 In-class work periods for the project

Calendar¶

This week¶

  • Today: Day 18 Agent Based Models
  • Thursday: Day 19 Perceptron model

Thanksgiving week¶

  • Tuesday 11/24: Project work day 1
  • Thursday 11/26: No class

Week after Thanksgiving¶

  • Tuesday 12/1: Day 20 Neural Networks 1
  • Thursday 12/3: Day 21 Neural Networks 2

Last week of classes¶

  • Tuesday 12/8: Project work day 2
  • Thursday 12/10: Project work day 3

Today¶

  • You will be given working code for the superbugs program
    • You will need to investigate how it works and how to implement it
  • You will come up with scientific questions to investigate with the program
    • Your group will present your scientific question and results at the end of class

You will have to animate a graph.

Animating a graph¶

  • There are many ways to do this, but we can use IPython.display to produce and clear output.

We will need to import:

  • from IPython.display import display, clear_output

  • import matplotlib.pylab as plt

In [12]:
from IPython.display import display, clear_output
import matplotlib.pylab as plt
import numpy as np

fig, ax = plt.subplots(figsize=(5,5))

x = np.arange(10)
y = x**2

plt.plot(x,y,'*')
Out[12]:
[<matplotlib.lines.Line2D at 0x7f9f10f776d0>]
In [19]:
from IPython.display import display, clear_output
import matplotlib.pylab as plt
import numpy as np

fig, ax = plt.subplots(figsize=(5,5))

#### SUPER BUGS ####
x_list=[]
y_list=[]

for x in np.arange(9):

    x_list.append(x)
    y_list.append(x**2)

    plt.plot(x_list, y_list, '*')
    plt.axis([0, 9, 0, 81])
#### SUPER BUGS ####

    ## Stay the same
    clear_output(wait=True) # clears display
    display(fig) # resets display
    fig.clear() # stops overlapping
<Figure size 360x360 with 0 Axes>

Questions, Comments, Concerns?¶