Kaggle competition: LANL Earthquake Prediction
<SOS> metric: MAE Kaggle data source: lanl-earthquake-prediction<choose_model_class>
train = pd.read_csv('.. /input/eq-100-features/train_100.csv')
 test = pd.read_csv('.. /input/eq-100-features/test_100.csv')
 y = pd.read_csv('.. /input/eq-100-features/y.csv' ).values.flatten()
EarlyStop_callback = keras.callbacks.EarlyStopping(monitor='val_loss', patience=10, restore_best_weights=True)
 my_callback=[EarlyStop_callback]<train_model>
warnings.filterwarnings('ignore')
 NUM_EVALS = 1000
N_FOLDS = 5
LGBM_MAX_LEAVES = 2**10
LGBM_MAX_DEPTH = 25
EVAL_METRIC_LGBM_REG = 'mae'
EVAL_METRIC_LGBM_CLASS = 'auc'
XGB_MAX_LEAVES = 2**12
XGB_MAX_DEPTH = 25
EVAL_METRIC_XGB_REG = 'mae'
EVAL_METRIC_XGB_CLASS = 'auc'
CB_MAX_DEPTH = 8
OBJECTIVE_CB_REG = 'MAE'
OBJECTIVE_CB_CLASS = 'Logloss'
BEST_SCORE = 0
def quick_hyperopt(data, labels, package='lgbm', num_evals=NUM_EVALS, diagnostic=False, Class=False):
if package=='lgbm':
print('Running {} rounds of LightGBM parameter optimisation:'.format(num_evals))
gc.collect()
integer_params = ['max_depth',
'num_leaves',
'max_bin',
'min_data_in_leaf',
'min_data_in_bin']
def objective(space_params):
for param in integer_params:
space_params[param] = int(space_params[param])
 if space_params['boosting']['boosting'] == 'goss':
top_rate = space_params['boosting'].get('top_rate')
 other_rate = space_params['boosting'].get('other_rate')
 top_rate = max(top_rate, 0)
 top_rate = min(top_rate, 0.5)
 other_rate = max(other_rate, 0)
 other_rate = min(other_rate, 0.5)
 space_params['top_rate'] = top_rate
space_params['other_rate'] = other_rate
subsample = space_params['boosting'].get('subsample', 1.0)
 space_params['boosting'] = space_params['boosting']['boosting']
space_params['subsample'] = subsample
if Class:
cv_results = lgb.cv(space_params, train, nfold = N_FOLDS, stratified=True,
early_stopping_rounds=100, metrics=EVAL_METRIC_LGBM_CLASS, seed=42)
 best_loss = 1 - cv_results['auc-mean'][-1]
else:
cv_results = lgb.cv(space_params, train, nfold = N_FOLDS, stratified=False,
early_stopping_rounds=100, metrics=EVAL_METRIC_LGBM_REG, seed=42)
 best_loss = cv_results['l1-mean'][-1]
return{'loss':best_loss, 'status': STATUS_OK }
train = lgb.Dataset(data, labels)
 boosting_list = [{'boosting': 'gbdt',
'subsample': hp.uniform('subsample', 0.5, 1)},
{'boosting': 'goss',
'subsample': 1.0,
'top_rate': hp.uniform('top_rate', 0, 0.5),
'other_rate': hp.uniform('other_rate', 0, 0.5)}]
if Class:
metric_list = ['auc']
objective_list = ['binary', 'cross_entropy']
else:
metric_list = ['MAE', 'RMSE']
objective_list = ['huber', 'gamma', 'fair', 'tweedie']
space ={'boosting' : hp.choice('boosting', boosting_list),
'num_leaves' : hp.quniform('num_leaves', 2, LGBM_MAX_LEAVES, 1),
'max_depth': hp.quniform('max_depth', 2, LGBM_MAX_DEPTH, 1),
'max_bin': hp.quniform('max_bin', 32, 255, 1),
'min_data_in_leaf': hp.quniform('min_data_in_leaf', 1, 256, 1),
'min_data_in_bin': hp.quniform('min_data_in_bin', 1, 256, 1),
'min_gain_to_split' : hp.quniform('min_gain_to_split', 0.1, 5, 0.01),
'lambda_l1' : hp.uniform('lambda_l1', 0, 5),
'lambda_l2' : hp.uniform('lambda_l2', 0, 5),
'learning_rate' : hp.loguniform('learning_rate', np.log(0.005), np.log(0.2)) ,
'metric' : hp.choice('metric', metric_list),
'objective' : hp.choice('objective', objective_list),
'feature_fraction' : hp.quniform('feature_fraction', 0.5, 1, 0.01),
'bagging_fraction' : hp.quniform('bagging_fraction', 0.5, 1, 0.01)
 }
trials = Trials()
best = fmin(fn=objective,
space=space,
algo=tpe.suggest,
max_evals=num_evals,
trials=trials)
 best['boosting'] = boosting_list[best['boosting']]['boosting']
best['metric'] = metric_list[best['metric']]
best['objective'] = objective_list[best['objective']]
for param in integer_params:
best[param] = int(best[param])
 print('{' + '
'.join('{}: {}'.format(k, v)for k, v in best.items())+ '}')
 if diagnostic:
return(best, trials)
 else:
return(best)
 if package=='xgb':
print('Running {} rounds of XGBoost parameter optimisation:'.format(num_evals))
gc.collect()
integer_params = ['max_depth']
def objective(space_params):
for param in integer_params:
space_params[param] = int(space_params[param])
 if space_params['tree_method']['tree_method'] == 'hist':
max_bin = space_params['tree_method'].get('max_bin')
 space_params['max_bin'] = int(max_bin)
 if space_params['tree_method']['grow_policy']['grow_policy']['grow_policy'] == 'depthwise':
grow_policy = space_params['tree_method'].get('grow_policy' ).get('grow_policy' ).get('grow_policy')
 space_params['grow_policy'] = grow_policy
space_params['tree_method'] = 'hist'
else:
max_leaves = space_params['tree_method']['grow_policy']['grow_policy'].get('max_leaves')
 space_params['grow_policy'] = 'lossguide'
space_params['max_leaves'] = int(max_leaves)
 space_params['tree_method'] = 'hist'
else:
space_params['tree_method'] = space_params['tree_method'].get('tree_method')
 cv_results = xgb.cv(space_params, train, nfold=N_FOLDS, metrics=[EVAL_METRIC_XGB_REG],
early_stopping_rounds=100, stratified=False, seed=42)
 best_loss = cv_results['test-mae-mean'].iloc[-1]
return{'loss':best_loss, 'status': STATUS_OK }
train = xgb.DMatrix(data, labels)
 boosting_list = ['gbtree', 'gblinear']
metric_list = ['MAE', 'RMSE']
tree_method = [{'tree_method' : 'exact'},
{'tree_method' : 'approx'},
{'tree_method' : 'hist',
'max_bin': hp.quniform('max_bin', 2**3, 2**7, 1),
'grow_policy' : {'grow_policy': {'grow_policy':'depthwise'},
'grow_policy' : {'grow_policy':'lossguide',
'max_leaves': hp.quniform('max_leaves', 32, XGB_MAX_LEAVES, 1)}}}]
objective_list_reg = ['reg:linear', 'reg:gamma', 'reg:tweedie']
objective_list_class = ['reg:logistic', 'binary:logistic']
objective_list = objective_list_reg
space ={'boosting' : hp.choice('boosting', boosting_list),
'tree_method' : hp.choice('tree_method', tree_method),
'max_depth': hp.quniform('max_depth', 2, XGB_MAX_DEPTH, 1),
'reg_alpha' : hp.uniform('reg_alpha', 0, 5),
'reg_lambda' : hp.uniform('reg_lambda', 0, 5),
'min_child_weight' : hp.uniform('min_child_weight', 0, 5),
'gamma' : hp.uniform('gamma', 0, 5),
'learning_rate' : hp.loguniform('learning_rate', np.log(0.005), np.log(0.2)) ,
'eval_metric' : hp.choice('eval_metric', metric_list),
'objective' : hp.choice('objective', objective_list),
'colsample_bytree' : hp.quniform('colsample_bytree', 0.1, 1, 0.01),
'colsample_bynode' : hp.quniform('colsample_bynode', 0.1, 1, 0.01),
'colsample_bylevel' : hp.quniform('colsample_bylevel', 0.1, 1, 0.01),
'subsample' : hp.quniform('subsample', 0.5, 1, 0.05),
'nthread' : -1
}
trials = Trials()
best = fmin(fn=objective,
space=space,
algo=tpe.suggest,
max_evals=num_evals,
trials=trials)
 best['tree_method'] = tree_method[best['tree_method']]['tree_method']
best['boosting'] = boosting_list[best['boosting']]
best['eval_metric'] = metric_list[best['eval_metric']]
best['objective'] = objective_list[best['objective']]
for param in integer_params:
best[param] = int(best[param])
 if 'max_leaves' in best:
best['max_leaves'] = int(best['max_leaves'])
 if 'max_bin' in best:
best['max_bin'] = int(best['max_bin'])
 print('{' + '
'.join('{}: {}'.format(k, v)for k, v in best.items())+ '}')
 if diagnostic:
return(best, trials)
 else:
return(best)
 if package=='cb':
print('Running {} rounds of CatBoost parameter optimisation:'.format(num_evals))
gc.collect()
integer_params = ['depth',
'min_data_in_leaf',
'max_bin']
def objective(space_params):
for param in integer_params:
space_params[param] = int(space_params[param])
 if space_params['bootstrap_type']['bootstrap_type'] == 'Bayesian':
bagging_temp = space_params['bootstrap_type'].get('bagging_temperature')
 space_params['bagging_temperature'] = bagging_temp
if space_params['grow_policy']['grow_policy'] == 'LossGuide':
max_leaves = space_params['grow_policy'].get('max_leaves')
 space_params['max_leaves'] = int(max_leaves)
 space_params['bootstrap_type'] = space_params['bootstrap_type']['bootstrap_type']
space_params['grow_policy'] = space_params['grow_policy']['grow_policy']
space_params['random_strength'] = max(space_params['random_strength'], 0)
 space_params['fold_len_multiplier'] = max(space_params['fold_len_multiplier'], 1)
 cv_results = cb.cv(train, space_params, fold_count=N_FOLDS,
early_stopping_rounds=25, stratified=False, partition_random_seed=42)
 best_loss = cv_results['test-MAE-mean'].iloc[-1]
return{'loss':best_loss, 'status': STATUS_OK}
train = cb.Pool(data, labels.astype('float32'))
bootstrap_type = [{'bootstrap_type':'Poisson'},
{'bootstrap_type':'Bayesian',
'bagging_temperature' : hp.loguniform('bagging_temperature', np.log(1), np.log(50)) },
{'bootstrap_type':'Bernoulli'}]
LEB = ['No', 'AnyImprovement', 'Armijo']
grow_policy = [{'grow_policy':'SymmetricTree'},
{'grow_policy':'Depthwise'},
{'grow_policy':'Lossguide',
'max_leaves': hp.quniform('max_leaves', 2, 32, 1)}]
eval_metric_list_reg = ['MAE', 'RMSE', 'Poisson']
eval_metric_list_class = ['Logloss', 'AUC', 'F1']
eval_metric_list = eval_metric_list_reg
space ={'depth': hp.quniform('depth', 2, CB_MAX_DEPTH, 1),
'max_bin' : hp.quniform('max_bin', 1, 32, 1),
'l2_leaf_reg' : hp.uniform('l2_leaf_reg', 0, 5),
'min_data_in_leaf' : hp.quniform('min_data_in_leaf', 1, 50, 1),
'random_strength' : hp.loguniform('random_strength', np.log(0.005), np.log(5)) ,
'bootstrap_type' : hp.choice('bootstrap_type', bootstrap_type),
'learning_rate' : hp.uniform('learning_rate', 0.05, 0.25),
'eval_metric' : hp.choice('eval_metric', eval_metric_list),
'objective' : OBJECTIVE_CB_REG,
'leaf_estimation_backtracking' : hp.choice('leaf_estimation_backtracking', LEB),
'grow_policy': hp.choice('grow_policy', grow_policy),
'fold_len_multiplier' : hp.loguniform('fold_len_multiplier', np.log(1.01), np.log(2.5)) ,
'od_type' : 'Iter',
'od_wait' : 25,
'task_type' : 'GPU',
'verbose' : 0
}
trials = Trials()
best = fmin(fn=objective,
space=space,
algo=tpe.suggest,
max_evals=num_evals,
trials=trials)
 best['bootstrap_type'] = bootstrap_type[best['bootstrap_type']]['bootstrap_type']
best['grow_policy'] = grow_policy[best['grow_policy']]['grow_policy']
best['eval_metric'] = eval_metric_list[best['eval_metric']]
best['leaf_estimation_backtracking'] = LEB[best['leaf_estimation_backtracking']]
for param in integer_params:
best[param] = int(best[param])
 if 'max_leaves' in best:
best['max_leaves'] = int(best['max_leaves'])
 print('{' + '
'.join('{}: {}'.format(k, v)for k, v in best.items())+ '}')
 if diagnostic:
return(best, trials)
 else:
return(best)
 else:
print('Package not recognised.Please use "lgbm" for LightGBM, "xgb" for XGBoost or "cb" for CatBoost.' )
dnn = keras.models.Sequential([
InputLayer(final_features.shape[1:]),
Dropout(0.7),
Dense(n_classes, activation='softmax')
 ])
 dnn.compile(optimizer='adam',
loss='categorical_crossentropy',
metrics=['accuracy'])
 h = dnn.fit(final_features, y,
batch_size=128,
epochs=60,
validation_split=0.1,
callbacks=my_callback )<categorify>
lgbm_params = quick_hyperopt(train, y, 'lgbm', 150 )
def images_to_array2(data_dir, labels_dataframe, img_size =(224,224,3)) :

 images_names = labels_dataframe['id']
data_size = len(images_names)
 X = np.zeros([data_size, img_size[0], img_size[1], 3], dtype=np.uint8)
 for i in tqdm(range(data_size)) :
image_name = images_names[i]
img_dir = os.path.join(data_dir, image_name+'.jpg')
 img_pixels = tf.keras.preprocessing.image.load_img(img_dir, target_size=img_size)
 X[i] = img_pixels
print('Ouptut Data Size: ', X.shape)
 return X
test_data = images_to_array2(test_dir, sample_df, img_size )<feature_engineering>
def quick_kfold_imp(X, y, test=None, params=None, n_fold=5, random_state=42):
MAE = 0
folds = KFold(n_splits=n_fold, shuffle=True, random_state=random_state)
 test_preds = np.zeros(len(test))
imp_s = np.zeros(X.shape[1])
 imp_g = np.zeros(X.shape[1])
 if type(y)is not np.ndarray:
y = y.values.flatten()
for train_idx, valid_idx in folds.split(y):
X_train, X_valid = X.iloc[train_idx, :], X.iloc[valid_idx, :]
y_train, y_valid = y[train_idx], y[valid_idx]
model = lgb.LGBMRegressor(**params, n_estimators = 50000, n_jobs = -1, eval_metric='mae', importance_type='split')
 model.fit(X_train, y_train,eval_set=[(X_train, y_train),(X_valid, y_valid)],
verbose=0, early_stopping_rounds=200)
 val_preds = model.predict(X_valid)
 imp_s += model.feature_importances_/n_fold
model = lgb.LGBMRegressor(**params, n_estimators = 50000, n_jobs = -1, eval_metric='mae', importance_type='gain')
 model.fit(X_train, y_train,eval_set=[(X_train, y_train),(X_valid, y_valid)],
verbose=0, early_stopping_rounds=200)
 val_preds = model.predict(X_valid)
 MAE += mean_absolute_error(y_valid, val_preds)/n_fold
imp_g += model.feature_importances_/n_fold
test_preds += model.predict(test)/n_fold
print('OOF MAE: {}'.format(MAE))
return(imp_s, imp_g, test_preds )
inception_features = get_features(InceptionV3, inception_preprocessor, img_size, test_data)
 xception_features = get_features(Xception, xception_preprocessor, img_size, test_data)
 nasnet_features = get_features(NASNetLarge, nasnet_preprocessor, img_size, test_data)
 inc_resnet_features = get_features(InceptionResNetV2, inc_resnet_preprocessor, img_size, test_data)
 test_features = np.concatenate([inception_features,
xception_features,
nasnet_features,
inc_resnet_features],axis=-1)
 print('Final feature maps shape', test_features.shape )<drop_column>
train_features = train.columns
imp_split = np.zeros(train.shape[1])
 imp_gain = np.zeros(train.shape[1])
 test_preds = np.zeros(len(test))
N=25
for i in range(0, N):
imp_s, imp_g, preds = quick_kfold_imp(train, y, test, lgbm_params, random_state=i)
 imp_split += imp_s/N
imp_gain += imp_g/N
test_preds += preds/N
initial_imp = pd.DataFrame({'feature':train_features,
'importance_split':imp_split,
'importance_gain':imp_gain,
'importance_score':np.log(( imp_split*imp_gain)) })
 initial_imp.sort_values('importance_score', ascending=False, inplace=True)
 initial_imp.head(10 )
del test_data<predict_on_test>
sub_1 = pd.read_csv('.. /input/LANL-Earthquake-Prediction/sample_submission.csv')
 sub_1['time_to_failure'] = test_preds
sub_1.to_csv('sub_orginal_data.csv', index=False)
 sub_1['time_to_failure'].hist()
y_pred = dnn.predict(test_features, batch_size=128 )<save_to_csv>
a = np.arange(0, train.shape[1])
 train_aug = pd.DataFrame(index=train.index, columns=train.columns, dtype='float64')
 for i in tqdm(range(0, len(train))):
AUG_FEATURE_RATIO = 0.5
AUG_FEATURE_COUNT = np.floor(train.shape[1]*AUG_FEATURE_RATIO ).astype('int16')
 aug_feature_index = np.random.choice(train.shape[1], AUG_FEATURE_COUNT, replace=False)
 aug_feature_index.sort()
feature_index = np.where(np.logical_not(np.in1d(a, aug_feature_index)))[0]
train_aug.iloc[i, feature_index] = train.iloc[i, feature_index]
rand_row_index = np.random.choice(len(train), len(aug_feature_index), replace=True)
 for n, j in enumerate(aug_feature_index):
train_aug.iloc[i, j] = train.iloc[rand_row_index[n], j]
for b in dog_breeds:
sample_df[b] = y_pred[:,class_to_num[b]]
sample_df.to_csv('pred.csv', index=None )<import_modules>
train_all = pd.concat([train, train_aug])
 y_all = np.append(y, y)
 print('Original train data shape: {}'.format(train.shape))
print('Augmented train data shape: {}'.format(train_all.shape))
params_all = quick_hyperopt(train_all, y_all, 'lgbm', 150 )
from collections import defaultdict
from functools import partial
from multiprocessing import cpu_count
from pathlib import Path
from textwrap import dedent<import_modules>
imp_split_all = np.zeros(train_aug.shape[1])
 imp_gain_all = np.zeros(train_aug.shape[1])
 test_preds_aug = np.zeros(len(test))
N = 25
for i in tqdm(range(0, N)) :
a = np.arange(0, train.shape[1])
 np.random.seed(i)
 train_aug = pd.DataFrame(index=train.index, columns=train.columns, dtype='float64')
 for i in range(0, len(train)) :
AUG_FEATURE_RATIO = 0.5
AUG_FEATURE_COUNT = np.floor(train.shape[1]*AUG_FEATURE_RATIO ).astype('int16')
 aug_feature_index = np.random.choice(train.shape[1], AUG_FEATURE_COUNT, replace=False)
 aug_feature_index.sort()
feature_index = np.where(np.logical_not(np.in1d(a, aug_feature_index)))[0]
train_aug.iloc[i, feature_index] = train.iloc[i, feature_index]
rand_row_index = np.random.choice(len(train), len(aug_feature_index), replace=True)
 for n, j in enumerate(aug_feature_index):
train_aug.iloc[i, j] = train.iloc[rand_row_index[n], j]
train_all = pd.concat([train, train_aug])
 imp_s, imp_g, preds = quick_kfold_imp(train_all, y_all, test, params=params_all, random_state=i)
 imp_split_all += imp_s/N
imp_gain_all += imp_g/N
test_preds_aug += preds/N
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from sklearn.externals import joblib
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import LabelEncoder, StandardScaler
import torch
from torch import nn
from torch import optim
from torch.nn import functional as F
from torch.optim.lr_scheduler import _LRScheduler
from torch.utils.data import TensorDataset, DataLoader<define_variables>
aug_imp = pd.DataFrame({'feature':train_features,
'importance_split':imp_split_all,
'importance_gain':imp_gain_all,
'importance_score':np.log(( imp_split_all*imp_gain_all)) })
 aug_imp.sort_values('importance_score', ascending=False, inplace=True)
 aug_imp.head(10 )
seed = 1
np.random.seed(seed )<define_variables>
sub_aug = pd.read_csv('.. /input/LANL-Earthquake-Prediction/sample_submission.csv')
 sub_aug['time_to_failure'] = test_preds_aug
sub_aug.to_csv('sub_aug_data.csv', index=False)
 sub_aug['time_to_failure'].hist()
sample = Path.cwd().parent/'input'/'career-con-2019'/'sample_submission.csv'<categorify>
scaler = MinMaxScaler()
initial_imp.iloc[:, 1:] = scaler.fit_transform(initial_imp.iloc[:, 1:])
 scaler = MinMaxScaler()
aug_imp.iloc[:, 1:] = scaler.fit_transform(aug_imp.iloc[:, 1:] )
ROOT = Path.cwd().parent/'input'/'career-con-2019-preprocessed-data'
enc = joblib.load(ROOT/'encoder.model')
 raw_arr = np.load(ROOT/'feat.npy' ).transpose(0, 2, 1)
 fft_arr = np.load(ROOT/'feat_fft.npy' ).transpose(0, 2, 1)
 target = np.load(ROOT/'target.npy')
 print(dedent(f))<split>
aug_cols = ['feature'] + [x + '_all' for x in aug_imp.columns if x != 'feature']
aug_imp.columns = aug_cols
feature_df = initial_imp.merge(aug_imp, on='feature', how='inner')
 feature_df['score_change'] = feature_df['importance_score_all'] - feature_df['importance_score']
feature_df.sort_values('score_change', ascending=False, inplace=True)
 feature_df.head(10 )
def create_datasets(data, target, train_size, valid_pct=0.1, seed=None):

 raw, fft = data
assert len(raw)== len(fft)
 sz = train_size
idx = np.arange(sz)
 trn_idx, val_idx = train_test_split(
 idx, test_size=valid_pct, random_state=seed)
 trn_ds = TensorDataset(
 torch.tensor(raw[:sz][trn_idx] ).float() ,
torch.tensor(fft[:sz][trn_idx] ).float() ,
torch.tensor(target[:sz][trn_idx] ).long())
 val_ds = TensorDataset(
 torch.tensor(raw[:sz][val_idx] ).float() ,
torch.tensor(fft[:sz][val_idx] ).float() ,
torch.tensor(target[:sz][val_idx] ).long())
 tst_ds = TensorDataset(
 torch.tensor(raw[sz:] ).float() ,
torch.tensor(fft[sz:] ).float() ,
torch.tensor(target[sz:] ).long())
 return trn_ds, val_ds, tst_ds<load_pretrained>
MIN_SCORE = np.percentile(feature_df.score_change.values.flatten() , 20)
 features = feature_df.loc[feature_df.score_change >= MIN_SCORE, :].feature.values.flatten()
train = train[features]
test = test[features]
params_final = quick_hyperopt(train, y, 'lgbm', 150)
 test_preds_final = np.zeros(len(test))
N = 30
for i in tqdm(range(0, N)) :
a = np.arange(0, train.shape[1])
 np.random.seed(i)
 train_aug = pd.DataFrame(index=train.index, columns=train.columns, dtype='float64')
 for i in range(0, len(train)) :
AUG_FEATURE_RATIO = 0.5
AUG_FEATURE_COUNT = np.floor(train.shape[1]*AUG_FEATURE_RATIO ).astype('int16')
 aug_feature_index = np.random.choice(train.shape[1], AUG_FEATURE_COUNT, replace=False)
 aug_feature_index.sort()
feature_index = np.where(np.logical_not(np.in1d(a, aug_feature_index)))[0]
train_aug.iloc[i, feature_index] = train.iloc[i, feature_index]
rand_row_index = np.random.choice(len(train), len(aug_feature_index), replace=True)
 for n, j in enumerate(aug_feature_index):
train_aug.iloc[i, j] = train.iloc[rand_row_index[n], j]
train_all = pd.concat([train, train_aug])
 _, _, preds = quick_kfold_imp(train_all, y_all, test, params=params_final, random_state=i)
 test_preds_final += preds/N
sub_final = pd.read_csv('.. /input/LANL-Earthquake-Prediction/sample_submission.csv')
 sub_final['time_to_failure'] = test_preds_final
sub_final.to_csv('sub_quintile_features_removed.csv', index=False)
 sub_final['time_to_failure'].hist()