Kaggle competition: COVID19 Global Forecasting (Week 4)
roc_auc = metrics.roc_auc_score(oof_target, oof_prediction)
 print('Our out of folds roc auc score is: ', roc_auc )<define_variables>
train_df = pd.read_csv(sorted(paths)[-1])
 test_df = pd.read_csv(sorted(paths)[-2])
 submission = pd.read_csv(sorted(paths)[-3])
 sub_08_04 = pd.read_csv(sorted(paths)[-5] )
colab=0
show_files=0
tstamp=0<set_options>
from statsmodels.tsa.statespace.sarimax import SARIMAX
if colab:
drive.mount('/content/gdrive' )<install_modules>
count_len = len(train_df[train_df['Country_Region'] == 'Russia'])
 train_cc = []
train_f = []
count = 0
for i in range(int(len(train_df)/ count_len)) :
train_cc.append(train_df.ConfirmedCases[count:count+count_len].values.tolist())
 train_f.append(train_df.Fatalities[count:count+count_len].values.tolist())
 count += count_len
!pip install -q efficientnet<import_modules>
delta =(datetime.today().date() - date(2020, 4, 2)).days
print("Tensorflow version " + tf.__version__)
 AUTO = tf.data.experimental.AUTOTUNE
if not colab: 
<define_variables>
test_count = len(test_df[test_df['Country_Region'] == 'Russia'])- delta - 1
predicted_cc = []
for i in range(len(train_cc)) :
try:
data1 = train_cc[i]
model1 = SARIMAX(data1, order=(1,1,0), seasonal_order=(1,1,0,12), measurement_error=True)
 model1_fit = model1.fit(disp=False)
 predicted1 = model1_fit.predict(len(data1), len(data1)+test_count)
 predicted_cc.append(predicted1.tolist())
 except:
data1 = train_cc[i]
model1 = SARIMAX(data1,order=(1,1,0),seasonal_order=(1,1,0,12),measurement_error=True,enforce_stationarity=False)
 model1_fit = model1.fit(disp=False)
 predicted1 = model1_fit.predict(len(data1), len(data1)+test_count)
 predicted_cc.append(predicted1.tolist() )
def seed_everything(seed):
random.seed(seed)
 np.random.seed(seed)
 os.environ['PYTHONHASHSEED'] = str(seed)
 tf.random.set_seed(seed )<load_from_csv>
predicted_f = []
for i in range(len(train_f)) :
try:
data2 = train_f[i]
model2 = SARIMAX(data2,order=(1,1,0), seasonal_order=(1,1,0,12), measurement_error=True)
 model2_fit = model2.fit(disp=False)
 predicted2 = model2_fit.predict(len(data2), len(data2)+test_count)
 predicted_f.append(predicted2.tolist())
 except:
data2 = train_f[i]
model2 = SARIMAX(data2,order=(1,1,0),seasonal_order=(1,1,0,12),measurement_error=True,enforce_stationarity=False)
 model2_fit = model2.fit(disp=False)
 predicted2 = model2_fit.predict(len(data2), len(data2)+test_count)
 predicted_f.append(predicted2.tolist() )
NAME='EffNB0_512'
NFOLDS=5
NBEST=2
SEED=311
n_max=7
if colab:
PATH=Path('/content/gdrive/My Drive/kaggle/input/siim-isic-melanoma-classification/')
 train=pd.read_csv(PATH/'train.csv.zip')
 else:
PATH=Path('/kaggle/input/siim-isic-melanoma-classification/')
 train=pd.read_csv(PATH/'train.csv')
 test=pd.read_csv(PATH/'test.csv')
 sub=pd.read_csv(PATH/'sample_submission.csv')
 seed_everything(SEED )<set_options>
check_lenght = len(train_cc[0][-delta:])+ len(predicted_cc[0])
 if check_lenght == 43:
print('Check OK')
 else:
print('Check failed' )
try:
tpu = tf.distribute.cluster_resolver.TPUClusterResolver()
print('Running on TPU ', tpu.master())
 except ValueError:
tpu = None
if tpu:
tf.config.experimental_connect_to_cluster(tpu)
 tf.tpu.experimental.initialize_tpu_system(tpu)
 strategy = tf.distribute.experimental.TPUStrategy(tpu)
 else:
strategy = tf.distribute.get_strategy()
print("REPLICAS: ", strategy.num_replicas_in_sync )<feature_engineering>
new_countries_idxs = [121, 166, 183, 210, 221, 299, 310]
GCS_PATH={}
if colab:
GCS_PATH['train']='gs://kds-4169ce1e5a624d4b5bd866480682658f2063b18c5cf995cd3316a7e9'
GCS_PATH['test']='gs://kds-147ff1400c195e2f8c7b01492e04fd2769e0305e9ef6c01afc9c5870'
GCS_PATH['hairs']='gs://kds-9e567a6e6d1255950cf43b26db187228f633ac7ec6bb6dcf70c1b511'
else:
GCS_PATH['train']=KaggleDatasets().get_gcs_path('siim-tfrec-cc-512-train')
 GCS_PATH['test']=KaggleDatasets().get_gcs_path('siim-tfrec-cc-512-test')
 GCS_PATH['hairs']=KaggleDatasets().get_gcs_path('melanoma-hairs')
 print(GCS_PATH['train'])
 print(GCS_PATH['test'])
 print(GCS_PATH['hairs'] )<define_variables>
days_from =(datetime.today().date() - date(2020, 4, 9)).days
%%time
IMAGE_SIZE = [512, 512]
EPOCHS=10
BATCH_SIZE = 8 * strategy.num_replicas_in_sync
CLASSES = ['benign', 'malignant']<feature_engineering>
sub_08_04[sub_08_04['Country_Region'] == 'Russia'].iloc[14:14+days_from]
ALL_TRAIN=tf.io.gfile.glob(GCS_PATH['train'] + '/*.tfrec')
 VAL_FNAMES={}
for fn in range(1, NFOLDS+1):
VAL_FNAMES[f"fold_{fn}"]=[path for path in ALL_TRAIN if f"fold_{fn}" in path]
print("Fold", f'{fn}:', len(VAL_FNAMES[f'fold_{fn}']), "elements in total.")
 TRAIN_FNAMES={f'fold_{i}': list(set(ALL_TRAIN)-set(VAL_FNAMES[f'fold_{i}']))
for i in range(1, NFOLDS+1)}
TEST_FNAMES = tf.io.gfile.glob(GCS_PATH['test'] + '/*.tfrec')
 hair_images=tf.io.gfile.glob(GCS_PATH['hairs'] + '/*.png' )<groupby>
train_df[train_df['Country_Region'] == 'Russia'].iloc[78:78+days_from]
def count_data_items(filenames):
n = [int(re.compile(r"-([0-9]*)\." ).search(filename ).group(1)) for filename in filenames]
return np.sum(n )<define_variables>
sub_count_len = len(sub_08_04[sub_08_04['Country_Region'] == 'Russia'])
 sub_0804_cc_preds = []
sub_0804_f_preds = []
sub_count = 0
for i in range(int(len(sub_08_04)/ sub_count_len)) :
sub_0804_cc_preds.append(sub_08_04.ConfirmedCases[sub_count+14:sub_count+14+days_from].values.tolist())
 sub_0804_f_preds.append(sub_08_04.Fatalities[sub_count+14:sub_count+14+days_from].values.tolist())
 sub_count += sub_count_len
%%time
N_TRAIN_IMGS = {f'fold_{i}': count_data_items(TRAIN_FNAMES[f'fold_{i}'])
 for i in range(1, NFOLDS+1)}
N_VAL_IMGS = {f'fold_{i}': count_data_items(VAL_FNAMES[f'fold_{i}'])
 for i in range(1, NFOLDS+1)}
N_TEST_IMGS = count_data_items(TEST_FNAMES)
 STEPS_PER_EPOCH = {f'fold_{i}': N_TRAIN_IMGS[f'fold_{i}'] // BATCH_SIZE
for i in range(1, NFOLDS+1)}
print("="*75)
 print(f"The number of unlabeled test image is {N_TEST_IMGS}.It is common for all folds.")
 for i in range(1, NFOLDS+1):
print("="*75)
 print(f"Fold {i}: {N_TRAIN_IMGS[f'fold_{i}']} training and {N_VAL_IMGS[f'fold_{i}']} validation images.")
 print("="*75 )<categorify>
train_count_len = len(train_df[train_df['Country_Region'] == 'Russia'])
 train_cc_act = []
train_f_act = []
train_count = 0
for i in range(int(len(train_df)/ train_count_len)) :
train_cc_act.append(train_df.ConfirmedCases[train_count+78:train_count+78+days_from].values.tolist())
 train_f_act.append(train_df.Fatalities[train_count+78:train_count+78+days_from].values.tolist())
 train_count += train_count_len
def decode_image(image_data):
image = tf.image.decode_jpeg(image_data, channels=3)
 image = tf.cast(image, tf.float32)/ 255.0
image = tf.reshape(image, [*IMAGE_SIZE, 3])
 return image<prepare_x_and_y>
train_0804_cc_act = []
train_0804_f_act = []
for i in range(len(train_cc_act)) :
if i not in new_countries_idxs:
train_0804_cc_act.append(train_cc_act[i])
 train_0804_f_act.append(train_f_act[i] )
def read_labeled_tfrecord(example):
LABELED_TFREC_FORMAT = {
"image": tf.io.FixedLenFeature([], tf.string),
"image_name": tf.io.FixedLenFeature([], tf.string),
"patient_id": tf.io.FixedLenFeature([], tf.string),
"benign_malignant": tf.io.FixedLenFeature([], tf.string),
"age": tf.io.FixedLenFeature([], tf.int64),
"sex_female": tf.io.FixedLenFeature([], tf.int64),
"sex_male": tf.io.FixedLenFeature([], tf.int64),
"sex_unknown": tf.io.FixedLenFeature([], tf.int64),
"site_head/neck": tf.io.FixedLenFeature([], tf.int64),
"site_lower extremity": tf.io.FixedLenFeature([], tf.int64),
"site_oral/genital": tf.io.FixedLenFeature([], tf.int64),
"site_palms/soles": tf.io.FixedLenFeature([], tf.int64),
"site_torso": tf.io.FixedLenFeature([], tf.int64),
"site_unknown": tf.io.FixedLenFeature([], tf.int64),
"site_upper extremity": tf.io.FixedLenFeature([], tf.int64),
"height": tf.io.FixedLenFeature([], tf.int64),
"width": tf.io.FixedLenFeature([], tf.int64),
"target": tf.io.FixedLenFeature([], tf.int64),
"age_scaled": tf.io.FixedLenFeature([], tf.float32),
}
example = tf.io.parse_single_example(example, LABELED_TFREC_FORMAT)
 image = decode_image(example['image'])
 data={}
data['image_name']=image_name=tf.cast(example['image_name'], tf.string)
 data['patient_id']=tf.cast(example['patient_id'], tf.string)
 data['age']=tf.cast(example['age'], tf.int32)
 data['sex_female']=tf.cast(example['sex_female'], tf.int32)
 data['sex_male']=tf.cast(example['sex_male'], tf.int32)
 data['sex_unknown']=tf.cast(example['sex_unknown'], tf.int32)
 data['site_head/neck']=tf.cast(example['site_head/neck'], tf.int32)
 data['site_lower extremity']=tf.cast(example['site_lower extremity'], tf.int32)
 data['site_oral/genital']=tf.cast(example['site_oral/genital'], tf.int32)
 data['site_palms/soles']=tf.cast(example['site_palms/soles'], tf.int32)
 data['site_torso']=tf.cast(example['site_torso'], tf.int32)
 data['site_unknown']=tf.cast(example['site_unknown'], tf.int32)
 data['site_upper extremity']=tf.cast(example['site_upper extremity'], tf.int32)
 data['age_scaled']=tf.cast(example['age_scaled'], tf.float32)
 label=tf.cast(example['target'], tf.int32)
 label_name=tf.cast(example['benign_malignant'], tf.string)
 return image, label, data, label_name<prepare_x_and_y>
div_act_sub_cc = []
div_act_sub_f = []
for i in range(len(train_0804_cc_act)) :
div_act_sub_cc.append([train_0804_cc_act[i][0] / sub_0804_cc_preds[i][0],
train_0804_cc_act[i][1] / sub_0804_cc_preds[i][1]])
 div_act_sub_f.append([(train_0804_f_act[i][0]+1)/(sub_0804_f_preds[i][0]+1), 
(train_0804_f_act[i][1]+1)/(sub_0804_f_preds[i][1]+1)] )
def read_unlabeled_tfrecord(example):
UNLABELED_TFREC_FORMAT = {
"image": tf.io.FixedLenFeature([], tf.string),
"image_name": tf.io.FixedLenFeature([], tf.string),
"patient_id": tf.io.FixedLenFeature([], tf.string),
"age": tf.io.FixedLenFeature([], tf.int64),
"sex_female": tf.io.FixedLenFeature([], tf.int64),
"sex_male": tf.io.FixedLenFeature([], tf.int64),
"sex_unknown": tf.io.FixedLenFeature([], tf.int64),
"site_head/neck": tf.io.FixedLenFeature([], tf.int64),
"site_lower extremity": tf.io.FixedLenFeature([], tf.int64),
"site_oral/genital": tf.io.FixedLenFeature([], tf.int64),
"site_palms/soles": tf.io.FixedLenFeature([], tf.int64),
"site_torso": tf.io.FixedLenFeature([], tf.int64),
"site_unknown": tf.io.FixedLenFeature([], tf.int64),
"site_upper extremity": tf.io.FixedLenFeature([], tf.int64),
"height": tf.io.FixedLenFeature([], tf.int64),
"width": tf.io.FixedLenFeature([], tf.int64),
"age_scaled": tf.io.FixedLenFeature([], tf.float32),
}
example = tf.io.parse_single_example(example, UNLABELED_TFREC_FORMAT)
 image = decode_image(example['image'])
 data={}
data['image_name']=image_name=tf.cast(example['image_name'], tf.string)
 data['patient_id']=tf.cast(example['patient_id'], tf.string)
 data['age']=tf.cast(example['age'], tf.int32)
 data['sex_female']=tf.cast(example['sex_female'], tf.int32)
 data['sex_male']=tf.cast(example['sex_male'], tf.int32)
 data['sex_unknown']=tf.cast(example['sex_unknown'], tf.int32)
 data['site_head/neck']=tf.cast(example['site_head/neck'], tf.int32)
 data['site_lower extremity']=tf.cast(example['site_lower extremity'], tf.int32)
 data['site_oral/genital']=tf.cast(example['site_oral/genital'], tf.int32)
 data['site_palms/soles']=tf.cast(example['site_palms/soles'], tf.int32)
 data['site_torso']=tf.cast(example['site_torso'], tf.int32)
 data['site_unknown']=tf.cast(example['site_unknown'], tf.int32)
 data['site_upper extremity']=tf.cast(example['site_upper extremity'], tf.int32)
 data['age_scaled']=tf.cast(example['age_scaled'], tf.float32)
 return image, data<create_dataframe>
cc_becs = []
f_becs = []
for i in range(len(div_act_sub_cc)) :
cc_becs.append(np.mean(div_act_sub_cc[i]))
f_becs.append(np.mean(div_act_sub_f[i]))
def load_dataset(filenames, labeled=True, ordered=False):
ignore_order = tf.data.Options()
if not ordered:
ignore_order.experimental_deterministic = False
dataset = tf.data.TFRecordDataset(filenames, num_parallel_reads=AUTO)
 dataset = dataset.with_options(ignore_order)
 dataset = dataset.map(read_labeled_tfrecord if labeled
else read_unlabeled_tfrecord, num_parallel_calls=AUTO)
 return dataset<train_model>
for idx in new_countries_idxs:
cc_becs.insert(idx, 1)
 f_becs.insert(idx, 1 )
%%time
training_dataset = load_dataset(TRAIN_FNAMES['fold_2'])
 print("Example of the training data:")
 for image, label, data, label_name in training_dataset.take(1):
print("The image batch size:", image.numpy().shape)
 print("Label:", label.numpy())
 print("Label name:", label_name.numpy())
 print("Age:", data['age'].numpy())
 print("Age(scaled):", data['age_scaled'].numpy() )<train_model>
predicted_ConfirmedCases = []
predicted_Fatalities = []
for i in range(int(len(train_df)/ count_len)) :
predicted_ConfirmedCases.append(train_cc[i][-delta:])
 predicted_ConfirmedCases.append(predicted_cc[i])
 predicted_Fatalities.append(train_f[i][-delta:])
 predicted_Fatalities.append(predicted_f[i])
 predicted_ConfirmedCases = list(itertools.chain.from_iterable(predicted_ConfirmedCases))
predicted_Fatalities = list(itertools.chain.from_iterable(predicted_Fatalities))
%%time
validation_dataset = load_dataset(VAL_FNAMES['fold_2'])
 print("Examples of the validation data:")
 for image, label, data, label_name in validation_dataset.take(1):
print("The image batch size:", image.numpy().shape)
 print("Label:", label.numpy())
 print("Label name:", label_name.numpy())
 print("Age:", data['age'].numpy())
 print("Age(scaled):", data['age_scaled'].numpy() )<create_dataframe>
mod_predicted_cc = []
mod_predicted_f = []
part = 1
for i in range(len(predicted_cc)) :
mod_predicted_cc.append([x*(cc_becs[i]*part)for x in predicted_cc[i]])
 mod_predicted_f.append([x*(f_becs[i]*part)for x in predicted_f[i]] )
def get_test_dataset(ordered=False):
dataset = load_dataset(TEST_FNAMES, labeled=False, ordered=ordered)
 dataset = dataset.batch(BATCH_SIZE)
 dataset = dataset.prefetch(AUTO)
 return dataset<train_model>
mean_ConfirmedCases_preds = []
mean_Fatalities_preds = []
for i in range(int(len(predicted_ConfirmedCases))):
mean_ConfirmedCases_preds.append(predicted_ConfirmedCases[i] * 0.15 + m_predicted_ConfirmedCases[i] * 0.85)
 mean_Fatalities_preds.append(predicted_Fatalities[i] * 0.15 + m_predicted_Fatalities[i] * 0.85 )
%%time
test_dataset = get_test_dataset()
print("Examples of the test data:")
 for image, data in test_dataset.take(1):
print("The image batch size:", image.numpy().shape)
 print("Ages, 5 examples:", data['age'].numpy() [:5])
 print("Age(scaled), 5 examples:", data['age_scaled'].numpy() [:5])
<init_hyperparams>
submission['ConfirmedCases'] = predicted_ConfirmedCases
submission['Fatalities'] = predicted_Fatalities
LR_START = 0.000005
LR_MAX = 0.00000725 * strategy.num_replicas_in_sync
LR_MIN = 0.000005
LR_RAMPUP_EPOCHS = 5
LR_SUSTAIN_EPOCHS = 4
LR_EXP_DECAY =.8
def lrfn(epoch):
if epoch < LR_RAMPUP_EPOCHS:
lr =(LR_MAX - LR_START)/ LR_RAMPUP_EPOCHS * epoch + LR_START
elif epoch < LR_RAMPUP_EPOCHS + LR_SUSTAIN_EPOCHS:
lr = LR_MAX
else:
lr =(LR_MAX - LR_MIN)* LR_EXP_DECAY**(epoch - LR_RAMPUP_EPOCHS - LR_SUSTAIN_EPOCHS)+ LR_MIN
return lr
lr_callback = tf.keras.callbacks.LearningRateScheduler(lrfn, verbose = True)
 rng = [i for i in range(EPOCHS)]
y = [lrfn(x)for x in rng]
plt.plot(rng, y)
 print("Learning rate schedule: {:.3g} to {:.3g} to {:.3g}".format(y[0], max(y), y[-1]))<prepare_x_and_y>
submission1 = pd.DataFrame(data=submission.ForecastId, columns=['ForecastId'])
 submission1['ConfirmedCases'] = m_predicted_ConfirmedCases
submission1['Fatalities'] = m_predicted_Fatalities
train['target'].values
class_weights = class_weight.compute_class_weight(class_weight='balanced',
classes=np.unique(train['target'].values),
y=train['target'].values, 
)
 class_weights = {i : class_weights[i] for i in range(len(class_weights)) }
print(class_weights )<define_variables>
submission2 = pd.DataFrame(data=submission.ForecastId, columns=['ForecastId'])
 submission2['ConfirmedCases'] = mean_ConfirmedCases_preds
submission2['Fatalities'] = mean_Fatalities_preds
tab_feats=['age_scaled',
'sex_female',
'sex_male',
'sex_unknown',
'site_head/neck',
'site_lower extremity',
'site_oral/genital',
'site_palms/soles',
'site_torso',
'site_unknown',
'site_upper extremity',
]
N_TAB_FEATS=len(tab_feats)
 print(f"The number of tabular features is {N_TAB_FEATS}." )<choose_model_class>
concl_df = pd.read_csv(sorted(paths)[-2])
 concl_feats = ['ForecastId', 'Country_Region', 'Date']
conclusion = pd.concat([concl_df[concl_feats], submission[['ConfirmedCases', 'Fatalities']]], axis=1)
 concl1_df = pd.read_csv(sorted(paths)[-2])
 conclusion1 = pd.concat([concl1_df[concl_feats], submission1[['ConfirmedCases', 'Fatalities']]], axis=1)
 concl2_df = pd.read_csv(sorted(paths)[-2])
 conclusion2 = pd.concat([concl2_df[concl_feats], submission2[['ConfirmedCases', 'Fatalities']]], axis=1 )
%time
def get_model() :
with strategy.scope() :
pretrained_model = efn.EfficientNetB0(input_shape=(*IMAGE_SIZE, 3),
weights='imagenet',
include_top=False 
)
 pretrained_model.trainable = True
inp1 = tf.keras.layers.Input(shape=(*IMAGE_SIZE, 3), name='inp1')
 inp2 = tf.keras.layers.Input(shape=(N_TAB_FEATS), name='inp2')
 x=pretrained_model(inp1)
 x=tf.keras.layers.GlobalAveragePooling2D()(x)
 x=tf.keras.layers.Dense(512,
kernel_regularizer=tf.keras.regularizers.l2(l=0.01),
activation='relu' )(x)
 x=tf.keras.layers.Dropout(0.2 )(x)
 x=tf.keras.layers.Dense(256,
kernel_regularizer=tf.keras.regularizers.l2(l=0.01),
activation='relu' )(x)
 x=tf.keras.layers.Dropout(0.2 )(x)
 x=tf.keras.layers.Dense(128,
kernel_regularizer=tf.keras.regularizers.l2(l=0.01),
activation='relu' )(x)
 x=tf.keras.layers.Dropout(0.2 )(x)
 x=tf.keras.layers.Dense(64, kernel_regularizer=tf.keras.regularizers.l2(l=0.01),
activation='relu' )(x)
 x=tf.keras.layers.Dropout(0.2 )(x)
 y=tf.keras.layers.Dense(100,
kernel_regularizer=tf.keras.regularizers.l2(l=0.01),
activation='relu' )(inp2)
 concat=tf.keras.layers.concatenate([y, x])
 output = tf.keras.layers.Dense(1, activation='sigmoid', name='output' )(concat)
 model = tf.keras.models.Model(inputs=[inp1,inp2], outputs=[output])
 model.compile(
 optimizer='adam',
loss = 'binary_crossentropy',
metrics=[tf.keras.metrics.AUC() ], 
)
 return model<set_options>
region = 'Russia'
conclusion2[conclusion2['Country_Region'] == region]
del model
gc.collect()<define_variables>
original_cc = conclusion[conclusion['Country_Region'] == region]['ConfirmedCases'].values
corrected_cc = conclusion1[conclusion1['Country_Region'] == region]['ConfirmedCases'].values
mean_cc = conclusion2[conclusion2['Country_Region'] == region]['ConfirmedCases'].values
original_f = conclusion[conclusion['Country_Region'] == region]['Fatalities'].values
corrected_f = conclusion1[conclusion1['Country_Region'] == region]['Fatalities'].values
mean_f = conclusion2[conclusion2['Country_Region'] == region]['Fatalities'].values
date = conclusion[conclusion['Country_Region'] == region]['Date'].values
for i in range(len(date)) :
date[i] = date[i][5:]
fig,(ax1, ax2)= plt.subplots(2,1, figsize=(14,14), dpi=120)
 ax1.plot(date, original_cc, ':g', label='original SARIMAX')
 ax1.plot(date, corrected_cc, ':b', label='corrected SARIMAX')
 ax1.plot(date, mean_cc, 'r', label='weighted SARIMAX')
 ax2.plot(date, original_f, ':g', label='original SARIMAX')
 ax2.plot(date, corrected_f, ':b', label='corrected SARIMAX')
 ax2.plot(date, mean_f, 'r', label='weighted SARIMAX')
 ax1.set_title(f'ConfirmedCases differences {region}')
 ax1.set_xlabel('Date')
 ax1.set_xticklabels(date, rotation=40)
 ax1.set_ylabel('ConfirmedCases')
 ax1.legend(loc='best')
 ax1.grid()
ax2.set_title(f'Fatalities differences {region}')
 ax2.set_xlabel('Date')
 ax2.set_xticklabels(date, rotation=40)
 ax2.set_ylabel('Fatalities')
 ax2.legend(loc='best')
 ax2.grid()
plt.show() ;
if colab:
SAVE_FOLDER=NAME
if tstamp:
time_zone = pytz.timezone('America/Chicago')
 current_datetime = datetime.now(time_zone)
 ts=current_datetime.strftime("%m%d%H%M%S")
 SAVE_FOLDER+='_'+ts
SAVE_FOLDER=PATH/SAVE_FOLDER
if not os.path.exists(SAVE_FOLDER):
os.mkdir(SAVE_FOLDER)
 else:
SAVE_FOLDER=Path('/kaggle/working' )<find_best_params>
submission2.to_csv('submission.csv', index=False )