In [1]:
import os
import datetime
import pandas as pd
import numpy as np
from scipy.stats import linregress
import seaborn as sns
import matplotlib.pyplot as plt
%matplotlib inline
from pylab import rcParams
rcParams['figure.figsize'] = 20, 16
plt.style.use('ggplot')
In [2]:
experiment_files = ['../results/2_output.csv', '../results/3_output.csv', '../results/4_output.csv', '../results/1_output.csv']
hive_names = ['Cohort 1', 'Cohort 2', 'Normal Hive 1', 'Normal Hive 2']
experiment_df_list = []
for file in experiment_files:
df = pd.read_csv(file, comment='#', header = 0)
experiment_df_list.append(df)
print(experiment_df_list[0].dtypes)
print(experiment_df_list[0]['result_type'].unique())
experiment_df_list[0]
Out[2]:
In [3]:
real_result_df_list = []
for df in experiment_df_list:
real_df = df[(df['result_type'] == 'real') & (df['tag_type'] == 'All')].reset_index()
real_result_df_list.append(real_df)
real_result_df_list[0]
Out[3]:
In [4]:
extended_metrics = ['mean_all_tracked_speeds', 'mean_min_tracked_speeds', 'median_all_tracked_speeds', 'median_min_tracked_speeds', 'spread_all_tracked_all_xy', 'spread_all_tracked_individuals', 'spread_min_tracked_all_xy', 'spread_min_tracked_individuals']
metrics_names = ['Mean Speed All Bees Tracked', 'Mean Speed Filtered Bees', 'Median Speed All Bees Tracked', 'Median Speed Filtered Bees', 'Spread All Bees All Coordinates', 'Spread All Bees Individuals', 'Spread Filtered Bees All Coordinates', 'Spread Filtered Bees Individuals']
for k, metric in enumerate(extended_metrics):
for i, df in enumerate(real_result_df_list):
plt.plot(df[metric][0:25], marker='o', label='{}'.format(hive_names[i]))
plt.title(metrics_names[k])
plt.xlabel('Days')
plt.xlim(-0.5,24.5)
x_len = len(df[metric][0:25])
day_nums = []
[day_nums.extend(['', ii + 1]) for ii in range(int(x_len / 2))]
plt.xticks(range(x_len), day_nums)
plt.legend(loc='lower left')
for j, time_period in enumerate(real_result_df_list[0]['time_period'][0:25]):
if time_period == 'night':
plt.axvspan(j - 0.5, j + 0.5, facecolor='b', alpha=0.1, edgecolor='none')
else:
plt.axvspan(j - 0.5, j + 0.5, facecolor='y', alpha=0.1, edgecolor='none')
plt.show()
In [5]:
for i, df in enumerate(real_result_df_list):
x_len = 24
day_nums = []
[day_nums.extend(['', ii + 1]) for ii in range(int(x_len / 2))]
plt.plot(df['mean_node_degree'][0:25], marker='o', label='{} {}'.format(hive_names[i], 'mean node degree'))
plt.plot(df['median_node_degree'][0:25], marker='o', label='{} {}'.format(hive_names[i], 'median node degree'))
plt.title('{} Node Degree'.format(hive_names[i]))
plt.xlabel('Days')
plt.xticks(range(x_len), day_nums)
plt.xlim(-0.5,24.5)
plt.legend(loc='upper right')
for j, time_period in enumerate(real_result_df_list[0]['time_period'][0:25]):
if time_period == 'night':
plt.axvspan(j - 0.5, j + 0.5, facecolor='b', alpha=0.1, edgecolor='none')
else:
plt.axvspan(j - 0.5, j + 0.5, facecolor='y', alpha=0.1, edgecolor='none')
plt.show()
plt.plot(df['mean_density'][0:25], marker='o', label='{} {}'.format(hive_names[i], 'mean density'))
plt.plot(df['median_density'][0:25], marker='o', label='{} {}'.format(hive_names[i], 'median density'))
plt.title('{} Node Density'.format(hive_names[i]))
plt.xlabel('Days')
plt.xticks(range(x_len), day_nums)
plt.xlim(-0.5,24.5)
plt.legend(loc='upper right')
for j, time_period in enumerate(real_result_df_list[0]['time_period'][0:25]):
if time_period == 'night':
plt.axvspan(j - 0.5, j + 0.5, facecolor='b', alpha=0.1, edgecolor='none')
else:
plt.axvspan(j - 0.5, j + 0.5, facecolor='y', alpha=0.1, edgecolor='none')
plt.show()
plt.plot(df['mean_clustering'][0:25], marker='o', label='{} {}'.format(hive_names[i], 'mean clustering'))
plt.plot(df['median_clustering'][0:25], marker='o', label='{} {}'.format(hive_names[i], 'median clustering'))
plt.title('{} Node Clustering'.format(hive_names[i]))
plt.xlabel('Days')
plt.xticks(range(x_len), day_nums)
plt.xlim(-0.5,24.5)
plt.legend(loc='upper right')
for j, time_period in enumerate(real_result_df_list[0]['time_period'][0:25]):
if time_period == 'night':
plt.axvspan(j - 0.5, j + 0.5, facecolor='b', alpha=0.1, edgecolor='none')
else:
plt.axvspan(j - 0.5, j + 0.5, facecolor='y', alpha=0.1, edgecolor='none')
plt.show()
In [6]:
extended_metrics = ['mean_all_tracked_speeds', 'mean_min_tracked_speeds', 'median_all_tracked_speeds', 'median_min_tracked_speeds', 'spread_all_tracked_all_xy', 'spread_all_tracked_individuals', 'spread_min_tracked_all_xy', 'spread_min_tracked_individuals']
metrics_names = ['Mean Speed All Bees Tracked', 'Mean Speed Filtered Bees', 'Median Speed All Bees Tracked', 'Median Speed Filtered Bees', 'Spread All Bees All Coordinates', 'Spread All Bees Individuals', 'Spread Filtered Bees All Coordinates', 'Spread Filtered Bees Individuals']
for i, df in enumerate(real_result_df_list):
for j, metric in enumerate(extended_metrics):
plt.plot(df[metric][0:25], marker='o', label='{}'.format(metrics_names[j]))
x_len = 24
day_nums = []
[day_nums.extend(['', ii + 1]) for ii in range(int(x_len / 2))]
plt.title(hive_names[i])
plt.xlabel('Days')
plt.xlim(-0.5,24.5)
plt.xticks(range(x_len), day_nums)
plt.legend(loc='lower left')
for j, time_period in enumerate(real_result_df_list[0]['time_period'][0:25]):
if time_period == 'night':
plt.axvspan(j - 0.5, j + 0.5, facecolor='b', alpha=0.1, edgecolor='none')
else:
plt.axvspan(j - 0.5, j + 0.5, facecolor='y', alpha=0.1, edgecolor='none')
plt.show()
In [7]:
weather_metrics = ['cloudCover','dewPoint','humidity','pressure','temperature','visibility','windSpeed']
weather_metrics_names = ['Cloud Cover','Dewpoint','Humidity','Pressure','Temperature','Visibility','Wind Speed']
weather_files = ['../results/2_weather.csv', '../results/3_weather.csv', '../results/4_weather.csv', '../results/1_weather.csv']
weather_df_list = []
for file in weather_files:
df = pd.read_csv(file, comment='#', header = 0)
weather_df_list.append(df)
print(weather_df_list[0].dtypes)
weather_df_list[0].head()
Out[7]:
In [8]:
for jj, metric in enumerate(weather_metrics):
x_len = 24
day_nums = []
[day_nums.extend(['', i + 1]) for i in range(int(x_len / 2))]
for i, df in enumerate(weather_df_list):
plt.plot(df[metric][0:25], marker='o', label='{}'.format(hive_names[i]))
plt.title(weather_metrics_names[jj])
plt.xlabel('Days')
plt.xticks(range(x_len), day_nums)
plt.xlim(-0.5,24.5)
plt.legend(loc='lower left')
for j, time_period in enumerate(weather_df_list[0]['time_period'][0:25]):
if time_period == 'night':
plt.axvspan(j - 0.5, j + 0.5, facecolor='b', alpha=0.1, edgecolor='none')
else:
plt.axvspan(j - 0.5, j + 0.5, facecolor='y', alpha=0.1, edgecolor='none')
plt.show()
In [ ]:
In [ ]: