Now that you have test.csv
or some other outputs from your model, you might like to analyze or visualize the results. The first thing to do is to either make a copy, or copy the metadata from the first six lines of test.csv
so that the first line of the file is the column names.
Once you've done that, you can use the pandas
project to get the info into a dataframe:
%matplotlib inline
import matplotlib
import numpy as np
import matplotlib.pyplot as plt
import pandas
data_df = pandas.read_csv('test.csv')
(did you get an 'error tokenizing data'? If so, you probably forgot to delete the metadata from the csv file:
"BehaviorSpace results (NetLogo 6.0.4)"
"Virus.nlogo"
"exp01"
"08/28/2018 14:15:31:214 +0000"
"min-pxcor","max-pxcor","min-pycor","max-pycor"
"-17","17","-17","17"
Delete that, save, then try again.)
# let's sort the data. Here, we'll use `sort_values` appended to our data_df dataframe, and we'll tell it to sort against
# the [run number] column. The results will be stored in 'sorted'.
sorted = data_df.sort_values('[run number]')
sorted
[run number] | duration | turtle-shape | infectiousness | number-people | chance-recover | [step] | count turtles with [ sick? ] | count turtles with [ immune? ] | count turtles with [ not sick? and not immune? ] | ticks | |
---|---|---|---|---|---|---|---|---|---|---|---|
0 | 1 | 20 | person | 45 | 150 | 75 | 0 | 10 | 0 | 140 | 0 |
972 | 1 | 20 | person | 45 | 150 | 75 | 232 | 47 | 79 | 173 | 232 |
975 | 1 | 20 | person | 45 | 150 | 75 | 233 | 49 | 79 | 172 | 233 |
978 | 1 | 20 | person | 45 | 150 | 75 | 234 | 47 | 79 | 174 | 234 |
981 | 1 | 20 | person | 45 | 150 | 75 | 235 | 44 | 83 | 173 | 235 |
985 | 1 | 20 | person | 45 | 150 | 75 | 236 | 41 | 86 | 172 | 236 |
989 | 1 | 20 | person | 45 | 150 | 75 | 237 | 42 | 87 | 170 | 237 |
993 | 1 | 20 | person | 45 | 150 | 75 | 238 | 43 | 83 | 173 | 238 |
996 | 1 | 20 | person | 45 | 150 | 75 | 239 | 47 | 84 | 168 | 239 |
1001 | 1 | 20 | person | 45 | 150 | 75 | 240 | 50 | 80 | 170 | 240 |
1007 | 1 | 20 | person | 45 | 150 | 75 | 241 | 48 | 81 | 171 | 241 |
968 | 1 | 20 | person | 45 | 150 | 75 | 231 | 47 | 81 | 172 | 231 |
1010 | 1 | 20 | person | 45 | 150 | 75 | 242 | 46 | 84 | 170 | 242 |
1016 | 1 | 20 | person | 45 | 150 | 75 | 244 | 47 | 82 | 170 | 244 |
1023 | 1 | 20 | person | 45 | 150 | 75 | 245 | 46 | 81 | 172 | 245 |
1027 | 1 | 20 | person | 45 | 150 | 75 | 246 | 44 | 78 | 178 | 246 |
1031 | 1 | 20 | person | 45 | 150 | 75 | 247 | 46 | 77 | 176 | 247 |
1040 | 1 | 20 | person | 45 | 150 | 75 | 248 | 43 | 78 | 178 | 248 |
2082 | 1 | 20 | person | 45 | 150 | 75 | 519 | 75 | 30 | 193 | 519 |
1044 | 1 | 20 | person | 45 | 150 | 75 | 249 | 42 | 82 | 176 | 249 |
1047 | 1 | 20 | person | 45 | 150 | 75 | 250 | 43 | 81 | 176 | 250 |
1050 | 1 | 20 | person | 45 | 150 | 75 | 251 | 44 | 80 | 176 | 251 |
1054 | 1 | 20 | person | 45 | 150 | 75 | 252 | 48 | 80 | 172 | 252 |
1013 | 1 | 20 | person | 45 | 150 | 75 | 243 | 47 | 87 | 166 | 243 |
963 | 1 | 20 | person | 45 | 150 | 75 | 230 | 47 | 82 | 171 | 230 |
959 | 1 | 20 | person | 45 | 150 | 75 | 229 | 47 | 82 | 171 | 229 |
955 | 1 | 20 | person | 45 | 150 | 75 | 228 | 42 | 83 | 175 | 228 |
872 | 1 | 20 | person | 45 | 150 | 75 | 205 | 35 | 112 | 152 | 205 |
876 | 1 | 20 | person | 45 | 150 | 75 | 206 | 33 | 114 | 152 | 206 |
879 | 1 | 20 | person | 45 | 150 | 75 | 207 | 31 | 113 | 155 | 207 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
196 | 4 | 20 | person | 75 | 150 | 75 | 53 | 42 | 63 | 98 | 53 |
1370 | 4 | 20 | person | 75 | 150 | 75 | 351 | 88 | 147 | 63 | 351 |
1314 | 4 | 20 | person | 75 | 150 | 75 | 335 | 115 | 94 | 91 | 335 |
212 | 4 | 20 | person | 75 | 150 | 75 | 58 | 44 | 68 | 96 | 58 |
1309 | 4 | 20 | person | 75 | 150 | 75 | 334 | 113 | 94 | 91 | 334 |
1305 | 4 | 20 | person | 75 | 150 | 75 | 333 | 113 | 92 | 94 | 333 |
1219 | 4 | 20 | person | 75 | 150 | 75 | 316 | 78 | 85 | 137 | 316 |
1223 | 4 | 20 | person | 75 | 150 | 75 | 317 | 74 | 85 | 141 | 317 |
1226 | 4 | 20 | person | 75 | 150 | 75 | 318 | 83 | 78 | 139 | 318 |
1229 | 4 | 20 | person | 75 | 150 | 75 | 319 | 84 | 81 | 134 | 319 |
1233 | 4 | 20 | person | 75 | 150 | 75 | 320 | 87 | 81 | 131 | 320 |
1237 | 4 | 20 | person | 75 | 150 | 75 | 321 | 90 | 82 | 128 | 321 |
230 | 4 | 20 | person | 75 | 150 | 75 | 63 | 46 | 79 | 91 | 63 |
1242 | 4 | 20 | person | 75 | 150 | 75 | 322 | 99 | 82 | 119 | 322 |
226 | 4 | 20 | person | 75 | 150 | 75 | 62 | 49 | 75 | 89 | 62 |
1263 | 4 | 20 | person | 75 | 150 | 75 | 323 | 102 | 80 | 118 | 323 |
1683 | 4 | 20 | person | 75 | 150 | 75 | 432 | 101 | 101 | 98 | 432 |
223 | 4 | 20 | person | 75 | 150 | 75 | 61 | 45 | 74 | 93 | 61 |
1272 | 4 | 20 | person | 75 | 150 | 75 | 325 | 111 | 79 | 108 | 325 |
1276 | 4 | 20 | person | 75 | 150 | 75 | 326 | 113 | 79 | 106 | 326 |
220 | 4 | 20 | person | 75 | 150 | 75 | 60 | 44 | 73 | 94 | 60 |
1280 | 4 | 20 | person | 75 | 150 | 75 | 327 | 115 | 81 | 101 | 327 |
1284 | 4 | 20 | person | 75 | 150 | 75 | 328 | 120 | 79 | 101 | 328 |
1289 | 4 | 20 | person | 75 | 150 | 75 | 329 | 118 | 81 | 101 | 329 |
1293 | 4 | 20 | person | 75 | 150 | 75 | 330 | 117 | 81 | 101 | 330 |
216 | 4 | 20 | person | 75 | 150 | 75 | 59 | 43 | 71 | 94 | 59 |
1297 | 4 | 20 | person | 75 | 150 | 75 | 331 | 116 | 83 | 99 | 331 |
1301 | 4 | 20 | person | 75 | 150 | 75 | 332 | 117 | 85 | 96 | 332 |
1268 | 4 | 20 | person | 75 | 150 | 75 | 324 | 103 | 77 | 119 | 324 |
1041 | 4 | 20 | person | 75 | 150 | 75 | 267 | 47 | 183 | 68 | 267 |
2084 rows × 11 columns
# let's get the results from Run 1
# we add the .loc operator that will let us select rows where run number = 1.
# Then we store the new dataframe in run1.
# Extract the other three runs!
run1 = data_df.loc[data_df['[run number]'] == 1]
run1.plot.line(x='ticks', y="count turtles with [ sick? ]")
<matplotlib.axes._subplots.AxesSubplot at 0x7f65fdf951d0>
Well, that depends. We often get to the end of a process (or more appropriately, the end of the beginning), and are left with a distinct sense of 'so what'. Embrace that. It's telling you something. Perhaps we're graphing the wrong thing, or asking the wrong question. Or perhaps our experiment was set up poorly. There clearly is some dynamic at play here: try more exploratory visualizations of your data. Can you explain what is happening in this model? How does it force you to ask other questions - and what kinds of questions?
Explore the sample models on Netlogo Web. Are there any that seem like they'd be useful for archaeology? Try to get them running here. Run some experiments! These three notebook files should get you going asking some good questions.