from svrimg.utils.get_tables import get_pred_tables
egs = get_pred_tables(data_dir="../data/csvs/", remove_first_row=True)
egs.head()
help(get_pred_tables)
E.g., 1997_table_1598590650584.csv
egs = get_pred_tables(data_dir="../data/csvs/", example=False, remove_first_row=True)
egs.head()
from svrimg.utils.get_images import get_img_list
from svrimg.utils.map_helper import draw_box_plot
from svrimg.utils.pmmean import _run_pmm_one_variable
import matplotlib.pyplot as plt
%matplotlib inline
plt.rcParams['figure.figsize'] = 25, 25
plt.rcParams['xtick.labelsize'] = 20
plt.rcParams['ytick.labelsize'] = 20
plt.rcParams['axes.labelsize'] = 20
i = [8, 7, 5, 4, 2, 1]
for cls in ['Cellular', 'QLCS', 'Tropical', 'Other', 'Noise', 'Missing']:
sub = egs[egs["Class Name"]==cls].copy()
imgs = get_img_list(sub.index.values, "../data/tor/")
img = _run_pmm_one_variable(imgs)
ax = plt.subplot(4, 3, i.pop())
ax = draw_box_plot(ax, img, cbar_shrink=0.8)
ax.set_title(cls, fontsize=20)
ax.text(0, 130, "n={}".format(len(imgs)), fontsize=20)
plt.tight_layout()
from svrimg.utils.get_tables import get_svrgis_table
svrgis = get_svrgis_table(data_dir="../data/csvs/")
egs_join = egs.join(svrgis)
egs_join.head()
plt.rcParams['figure.figsize'] = 40, 40
plt.rcParams['xtick.labelsize'] = 20
plt.rcParams['ytick.labelsize'] = 20
plt.rcParams['axes.labelsize'] = 20
i = 1
for subset in [(1996, 2011), (2012, 2013), (2014, 2017)]:
sub_ = egs_join[(egs_join.yr >= subset[0]) & (egs_join.yr <= subset[1])].copy()
for cls in ['Cellular', 'QLCS', 'Tropical', 'Other', 'Noise', 'Missing']:
class_ = sub_[sub_["Class Name"]==cls].copy()
imgs = get_img_list(class_.index.values, "../data/tor/")
img = _run_pmm_one_variable(imgs)
ax = plt.subplot(6, 6, i)
ax = draw_box_plot(ax, img, cbar_shrink=0.8)
ax.set_title(cls + "\n{}-{}".format(subset[0], subset[1]), fontsize=30)
ax.text(0, 130, "n={}".format(len(imgs)), fontsize=35)
i += 1
plt.tight_layout()
import numpy as np
import pickle
for subset, name in zip([(1996, 2011), (2012, 2013), (2014, 2017)], ("train", "validation", "test")):
sub_ = egs_join[(egs_join.yr >= subset[0]) & (egs_join.yr <= subset[1])].copy()
imgs = get_img_list(sub_.index.values, "../data/tor/")
imgs = np.expand_dims(imgs, axis=3)
classes = sub_['Class Code'].values
## Assumes this folder exists
pickle.dump([imgs, classes], open("../data/pkls/{}_{}_{}.pkl".format(subset[0], subset[1], name), "wb"))
x_train, y_train = pickle.load(open("../data/pkls/1996_2011_train.pkl", "rb"))
x_val, y_val = pickle.load(open("../data/pkls/2012_2013_validation.pkl", "rb"))
x_test, y_test = pickle.load(open("../data/pkls/2014_2017_test.pkl", "rb"))