<jupyter_start><jupyter_text>Maps<jupyter_code>figure_size = (20, 20)

nhood_base = neighborhoods.plot(figsize=figure_size,
                                color='gray',
                                edgecolor='black',
                                alpha=.5)

streets_local = streets[streets['roadclass'] == 'Local'].plot(ax=nhood_base,
                                                              figsize=figure_size,
                                                              color='white',
                                                              alpha=.2)

streets_major = streets[streets['roadclass'] == 'Major Arterial'].plot(ax=streets_local,
                                                                       figsize=figure_size,
                                                                       color='green',
                                                                       alpha=.4)

streets_freeway = streets[streets['roadclass'] == 'Freeway'].plot(ax=streets_major,
                                                                  figsize=figure_size,
                                                                  color='blue',
                                                                  alpha=.5)
nhood_base = neighborhoods.plot(figsize=figure_size,
                                color='gray',
                                edgecolor='gray',
                                alpha=.5)

accidents.plot(ax=nhood_base, marker='*', color='red', markersize=1, alpha=.2)<jupyter_output><empty_output><jupyter_text>Charts<jupyter_code>plt.style.use('ggplot')
plt.rcParams['figure.figsize'][0] = 16
plt.rcParams['figure.figsize'][1] = 9
accident_samples = sample_data[sample_data['accident_yn'] == 1].copy()
months = ['Jan', 'Feb', 'Mar', 'Apr','May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
accident_samples['month'] = pd.Categorical(accident_samples.datetime.dt.strftime('%b'), categories=months)

days = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
accident_samples['day'] = pd.Categorical(accident_samples.datetime.dt.strftime('%a'), categories=days)<jupyter_output><empty_output><jupyter_text>Accident Counts by Date **Month**<jupyter_code>_ = accident_samples.groupby(['month']).size().plot(kind='bar')<jupyter_output><empty_output><jupyter_text>**Day of Week**<jupyter_code>_ = accident_samples.groupby(['day']).size().plot(kind='bar')<jupyter_output><empty_output><jupyter_text>**Hour of Day**<jupyter_code>accidents_by_day_hour = accident_samples.groupby(['day', 'hour']).size().reset_index()
accidents_by_day_hour.columns = ['day', 'hour', 'accidents']

accidents_by_day_hour_pivoted = accidents_by_day_hour.pivot('hour', 'day', 'accidents')

f, ax = plt.subplots(figsize=(20, 16))

_ = sns.heatmap(accidents_by_day_hour_pivoted, annot=True, fmt='d', linewidths=.5, ax=ax)<jupyter_output><empty_output><jupyter_text>**Daylight**<jupyter_code>_ = accident_samples.groupby(['daylight_yn']).size().plot(kind='bar')<jupyter_output><empty_output><jupyter_text>**Holiday**<jupyter_code>_ = accident_samples.groupby(['holiday_yn']).size().plot(kind='bar')<jupyter_output><empty_output><jupyter_text>**Rush Hour**<jupyter_code>_ = accident_samples.groupby(['rush_hour_yn']).size().plot(kind='bar')<jupyter_output><empty_output><jupyter_text>Weather Distribution **Temperature**<jupyter_code>_ = plt.hist(accident_samples.temp, bins=16)<jupyter_output><empty_output><jupyter_text>**Wind**<jupyter_code>_ = plt.hist(accident_samples.wind_speed, bins=25)<jupyter_output><empty_output><jupyter_text>**Precipitation**<jupyter_code>rain_plot = accident_samples[(accident_samples.precipitation > 0) & (accident_samples.precipitation < .5)].precipitation
_ = plt.hist(rain_plot, bins=25)<jupyter_output><empty_output><jupyter_text>Roads **Type**<jupyter_code>road_classes = ['class_freeway', 'class_local', 'class_major', 'class_other', 'class_unimproved']

_ = accident_samples[road_classes].idxmax(axis=1).value_counts().plot(kind='bar')<jupyter_output><empty_output><jupyter_text>**Length**<jupyter_code>_ = plt.subplot(2, 1, 1)
_ = plt.hist(accident_samples[accident_samples.road_length < 5280].road_length, bins=20)
_ = plt.title('Road Length (less than 1-mile)')
_ = plt.subplot(2, 1, 2)
_ = plt.hist(accident_samples[accident_samples.road_length >= 5280].road_length, bins=30)
_ = plt.title('Road Length (greater than 1-mile)')

plt.rcParams['figure.figsize'][0] = 16
plt.rcParams['figure.figsize'][1] = 20<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15492331629250944, 'fraction_numerical': 0.012669482107134918, 'mean_word_length': 3.1666666666666665, 'pattern_counts': {'":': 0, '<': 55, '<?xml version=': 0, '>': 55, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 21, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '13', 'dir': 'jupyter-structured-clean-dedup', 'id': '618668', 'license': 'MIT', 'n_tokens_mistral': 1522, 'n_tokens_neox': 1442, 'n_words': 148, 'path': 'notebooks/modeling/2.5-visual-exploration.ipynb', 'repo_name': 'jkgerig/nola-traffic-accidents', 'size': '4499'}