Kaggle competition: The Kaggle Master
<SOS> metric: auc Kaggle data source: the-kaggle-master<data_type_conversions>
%matplotlib inline
plt.style.use("dark_background" )
X_tr = []
Y_tr = []
imges = train_df['id'].values
for img_id in tqdm_notebook(imges):
X_tr.append(cv2.imread(train_dir + img_id))
Y_tr.append(train_df[train_df['id'] == img_id]['has_cactus'].values[0])
 X_tr = np.asarray(X_tr)
 X_tr = X_tr.astype('float32')
 X_tr /= 255
Y_tr = np.asarray(Y_tr )<define_variables>
def seed_everything(seed=1234):
random.seed(seed)
 os.environ['PYTHONHASHSEED'] = str(seed)
 tf.random.set_seed(seed)
 np.random.seed(seed)
 seed_everything(2020 )
batch_size = 16
nb_epoch = 30<choose_model_class>
main_dir = ".. /input/biobytes-contest"
datagen = ImageDataGenerator(featurewise_center=False,
",
samplewise_center=False,
",
featurewise_std_normalization=False,
",
samplewise_std_normalization=False,
",
zca_whitening=False,
",
zca_epsilon=1e-06,
",
rotation_range=20,
",
width_shift_range=0.2,
",
height_shift_range=0.2,
",
shear_range=0.2,
",
zoom_range=0.2,
",
channel_shift_range=0.,
",
fill_mode='nearest',
validation_split=0.1,
horizontal_flip=True,
vertical_flip=True)
 datagen.fit(X_tr)
 history = model.fit_generator(datagen.flow(X_tr, Y_tr, batch_size=batch_size, subset='training'),
validation_data=datagen.flow(X_tr, Y_tr, batch_size=batch_size, subset='validation'),
steps_per_epoch=len(X_tr)/ batch_size, epochs=nb_epoch, shuffle=True, validation_steps=len(X_tr)/batch_size )<data_type_conversions>
with open(f"{main_dir}/Main_data.txt")as f:
temp = f.read()
temp = temp[:temp.index('>', 1)]
print("When printed it looks like so:
".upper() + temp)
 print("Raw string:
".upper() + repr(temp))
%%time
X_tst = []
Test_imgs = []
for img_id in tqdm_notebook(os.listdir(test_dir)) :
X_tst.append(cv2.imread(test_dir + img_id))
Test_imgs.append(img_id)
 X_tst = np.asarray(X_tst)
 X_tst = X_tst.astype('float32')
 X_tst /= 255<predict_on_test>
data = pd.read_csv(
 f"{main_dir}/Main_data.txt",
sep='
', names=['Name', 'P_Seq', 'Target'],
lineterminator='>',
index_col=False 
)
 for name, value in zip(['Name', 'P_seq', 'Target'], data.iloc[0]):
print(f"{name}: {repr(value)}
" )
test_predictions = model.predict(X_tst )<create_dataframe>
test =(
 pd.read_csv(
 f"{main_dir}/Test_data.txt",
sep='
', names=['Name', 'P_Seq'],
lineterminator='>', index_col=False)
.applymap(lambda x: x.rstrip('\r')) 
)
 for name, value in zip(['Name', 'P_seq', 'Target'], test.iloc[0]):
print(f"{name}: {repr(value)}
" )
sub_df = pd.DataFrame(test_predictions, columns=['has_cactus'] )<feature_engineering>
sample_sub = pd.read_csv(f"{main_dir}/Sample_Solution.csv")
 sample_sub.head()
sub_df['id'] = ''
cols = sub_df.columns.tolist()
cols = cols[-1:] + cols[:-1]
sub_df=sub_df[cols]<prepare_output>
data['P_Main_Class'] = data.Name.str.extract(":(\w)")
 data['P_Sub_Class'] = data.Name.str.extract(" (.+):\w")
 data['Seq_len'] = data.P_Seq.apply(len)
 data['Uniq_seq_Count'] = data.P_Seq.apply(lambda x: len(set(x)))
 data['B_Site_Count'] = data.Target.str.count('1')
 data['B_Site_percent'] = data['B_Site_Count'] / data['Seq_len']
data['Non_B_Site_Count'] = data['Seq_len'] - data['B_Site_Count']
data.head()
for i, img in enumerate(Test_imgs):
sub_df.set_value(i,'id',img )<save_to_csv>
uniq = set()
for _, seq in data.P_Seq.iteritems() :
uniq |= set(seq)
 print(uniq)
 len(uniq )
sub_df.to_csv('submission.csv',index=False )<set_options>
pmc_mapper = dict(zip(temp[temp > 1].index, range(len(temp))))
print(pmc_mapper )
%matplotlib inline 
<import_modules>
psc_mapper = dict(zip(temp[temp > 1].index, range(len(temp))))
print(psc_mapper )
from keras.preprocessing.image import load_img, img_to_array
from os import listdir
import pandas as pd
import numpy as np<categorify>
temp = data.apply(lambda x: np.array(list(x[1])) [np.array(list(x[2])).astype(bool)], axis=1)
 temp = temp.apply(pd.Series ).stack().reset_index(level=1, drop=True)
 freq_occured = data.P_Seq.apply(lambda x: pd.Series(list(x)).value_counts() ).sum()
freq_bound = temp.value_counts()
freq = pd.merge(
 pd.DataFrame(freq_occured ).reset_index().rename({"index": "Peptide", 0: "Occured"}, axis=1),
pd.DataFrame(freq_bound ).reset_index().rename({"index": "Peptide", 0: "Bound"}, axis=1),
on='Peptide' 
)
 freq['Percent'] = freq['Bound'] / freq['Occured'] * 100
freq.head()
def loadImages(path):
count = 1
images = []
imageList = sorted(listdir(path))
for i in imageList:
image = load_img(path + i)
 image = img_to_array(image)
 images.append(image)
 if(count % 1000 == 0):
print("Processing image", count)
 count += 1
print("Done.")
 return np.asarray(images, dtype='float')
<prepare_x_and_y>
sub = test['P_Seq'].apply(list ).explode().reset_index()
sub = sub.rename({'index': 'Seq_No', "P_Seq": 'Peptide'}, axis=1)
 sub['Id'] = sub.index
sub = sub.iloc[:, [-1, 0, 1]]
sub.head()
path = ".. /input/aerial-cactus-identification/train/train/"
X_train = loadImages(path )<prepare_x_and_y>
sub["Expected"] = sub.groupby("Seq_No")['Id'].transform(lambda x:(np.random.random(len(x)) < 0.35 ).astype(int))
sub.head()
path = ".. /input/aerial-cactus-identification/test/test/"
X_test = loadImages(path )<load_from_csv>
sub[['Id', 'Expected']].to_csv("Naive_submission.csv", index=False )
Y_train = pd.read_csv(".. /input/aerial-cactus-identification/train.csv" )<sort_values>
mapper = dict(zip(freq.Peptide, freq.Percent))
print(mapper )
Y_train = Y_train.sort_values("id", ascending=True ).has_cactus<define_variables>
sub['Expected'] =(
 sub.Peptide.map(mapper)/ 100
> sub.groupby('Peptide')['Id'].transform(lambda x: np.random.random(len(x)))
 ).astype(int )
epochs = 3
batch_size = 32<import_modules>
temp = np.random.choice(list(mapper.keys()))
mapper[temp] / 100, sub.loc[sub.Peptide == temp, 'Expected'].mean()
from keras.applications.xception import Xception
from keras.applications.vgg16 import VGG16
from keras.applications.vgg19 import VGG19
from keras.applications.mobilenet import MobileNet
from keras.applications.densenet import DenseNet201
from keras.applications.nasnet import NASNetLarge<choose_model_class>
sub[['Id', 'Expected']].to_csv("Peptide_Based_Fprediction.csv", index=False )
learning_rate_reduction = ReduceLROnPlateau(monitor='val_acc', patience=3, verbose=1, \
factor=0.7, min_lr=0.00001 )<choose_model_class>
Y = data.Target.apply(list ).explode().values.astype(int)
 y_hat_naive =(np.random.random(len(Y)) < 0.35 ).astype(int)
 y_hat_freq_based =(
 data.P_Seq.apply(list ).explode().reset_index(drop=True ).map(mapper)/ 100
> 
(data.P_Seq.apply(list ).explode().to_frame().reset_index().groupby("P_Seq")
.transform(lambda x: np.random.random(len(x)))['index'])
 ).astype(int)
 print("Our estimates on TRAINING DATA:")
 print("
\tNaive model accuracy score: {:12.2f}
\tNaive model ROC score: {:17.2f}" 
.format(
 accuracy_score(Y, y_hat_naive),
roc_auc_score(Y, y_hat_naive)) 
)
 print("
\tNuanced Naive model accuracy score: {:.2f}
\tNuanced Naive model ROC score: {:9.2f}" 
.format(
 accuracy_score(Y, y_hat_freq_based),
roc_auc_score(Y, y_hat_freq_based))
)
datagen = ImageDataGenerator(rotation_range=30, width_shift_range=0.2,
height_shift_range=0.2, zoom_range=0.2,
horizontal_flip=True, vertical_flip=True,
validation_split=0.1 )<define_variables>
flat_data = pd.DataFrame({
"P_Seq": data.P_Seq.apply(list ).explode() ,
"Target": data.Target.apply(list ).explode().astype(int)
 })
 flat_data.head()
train_generator = datagen.flow(X_train, Y_train, batch_size=batch_size, subset='training')
 val_generator = datagen.flow(X_train, Y_train, batch_size=batch_size, subset='validation' )<choose_model_class>
tf.keras.backend.clear_session()
model = tf.keras.models.Sequential()
model.add(tf.keras.layers.Input(shape=(len(peptide_mapper),)))
 model.add(tf.keras.layers.Dense(1, activation='sigmoid'))
model.compile(loss='binary_crossentropy', optimizer='adam', metrics=tf.keras.metrics.AUC())
 model.summary()
def buildModel(base_model, freeze=0.8):
threshold = int(len(base_model.layers)* freeze)
 for i in base_model.layers[:threshold]:
i.trainable = False
for i in base_model.layers[threshold:]:
i.trainable = True
X = base_model.output
X = Flatten()(X)
 X = Dense(512, activation='relu', kernel_regularizer='l2' )(X)
 X = Dense(1, activation='sigmoid' )(X)
 model = Model(inputs=base_model.input, outputs=X)
 return model<train_model>
hist = model.fit(
 tf.one_hot(flat_data.P_Seq.map(peptide_mapper), depth=20),
flat_data.Target,
validation_split=0.2,
callbacks=tf.keras.callbacks.EarlyStopping(patience=10),
epochs=100,
verbose=0)
 print("Train Best ROC_AUC Score: {:.2f}".format(hist.history['auc'][-1]))
print("Val Best ROC_AUC Score: {:6.2f}".format(hist.history['val_auc'][-1]))
pd.DataFrame(hist.history ).iloc[:, [1, 3]].plot(figsize=(20, 5), title='Model Performance');
def fitModel(model, lr=0.0005, cp=False):
model.compile(optimizer=Adam(lr=lr), loss='binary_crossentropy', metrics=['accuracy'])
 cb = [learning_rate_reduction, checkpoint] if cp else [learning_rate_reduction]
history.append(model.fit_generator(generator=train_generator, epochs=epochs,
steps_per_epoch=int(X_train.shape[0] // batch_size * 1.5),
validation_data=val_generator,
validation_steps=int(X_train.shape[0] // batch_size * 0.4),
callbacks=cb, verbose=2))
return model<define_variables>
sub['Expected'] =(
 model.predict(tf.one_hot(
 sub.Peptide.map(peptide_mapper),
depth=len(peptide_mapper)))
 )
history = []<train_model>
sub[['Id', 'Expected']].to_csv("Linear_model_one_hot.csv", index=False )
X_input = Input(( 32, 32, 3))
base_model = Xception(weights=".. /input/pretrained-models/xception_weights_tf_dim_ordering_tf_kernels_notop.h5",
include_top=False, input_tensor=X_input)
 model = buildModel(base_model)
 fitModel(model )<train_model>
flat_data['Percent'] = flat_data.P_Seq.map(mapper ).astype(float)/ 100
flat_data = flat_data.merge(data.iloc[:, 3:7], right_index=True, left_index=True)
 flat_data['Position'] = flat_data.groupby(flat_data.index)['P_Seq'].transform(lambda x: np.arange(len(x)) / len(x))
flat_data.head()
X_input = Input(( 32, 32, 3))
base_model = VGG16(weights=".. /input/pretrained-models/vgg16_weights_tf_dim_ordering_tf_kernels_notop.h5",
include_top=False, input_tensor=X_input)
 model = buildModel(base_model)
 fitModel(model )<train_model>
test['P_Main_Class'] = test.Name.str.extract(":(\w)")
 test['P_Sub_Class'] = test.Name.str.extract(" (.+):\w")
 test['Seq_len'] = test.P_Seq.apply(len)
 test['Uniq_seq_Count'] = test.P_Seq.apply(lambda x: len(set(x)))
 sub = sub.set_index("Seq_No" ).merge(test.iloc[:, 2:], right_index=True, left_index=True)
 sub['Expected'] = sub.Peptide.map(mapper)/ 100
sub = sub.rename({"Peptide": "P_Seq", "Expected": "Percent"}, axis=1)
 sub['Position'] = sub.groupby(sub.index)['P_Seq'].transform(lambda x: np.arange(len(x)) / len(x))
sub.head(3 )
X_input = Input(( 32, 32, 3))
base_model = VGG19(weights=".. /input/pretrained-models/vgg19_weights_tf_dim_ordering_tf_kernels_notop.h5",
include_top=False, input_tensor=X_input)
 model = buildModel(base_model)
 fitModel(model )<train_model>
def process_flat_df(
 data,
ohc=[('P_Sub_Class', len(psc_mapper)) ,('P_Main_Class', len(pmc_mapper)) ],
dc=['P_Main_Class', 'P_Sub_Class'],
seq_shift=0,
pep_freq=None,
as_df=False):

 df = data.copy()
pmapper = peptide_mapper.copy()
pmapper['0'] = max(peptide_mapper.values())+ 1
if pep_freq is not None:
freq_mat = get_freq(pep_freq[0], fit=pep_freq[1])
 df = df.merge(freq_mat, left_index=True, right_index=True, how='left')
 df.iloc[:, -freq_mat.shape[1]:] = df.iloc[:, -freq_mat.shape[1]:] / df['Seq_len'].values.reshape(-1, 1)
 df['Seq_len'] = df['Seq_len'] / max(sub.Seq_len.max() , flat_data.Seq_len.max())
 df['Uniq_seq_Count'] = df['Uniq_seq_Count'] / 20
df['P_Main_Class'] = df['P_Main_Class'].map(pmc_mapper ).fillna(len(pmc_mapper))
df['P_Sub_Class'] = df['P_Sub_Class'].map(psc_mapper ).fillna(len(psc_mapper))
one_hot = []
for i in range(-seq_shift, seq_shift+1):
df[f'P_Seq_{i}'] = df.groupby(df.index)['P_Seq'].shift(-i ).fillna('0' ).map(pmapper)
 seq_one_hot = tf.reduce_sum(tf.one_hot(df.iloc[:, -(( seq_shift*2)+1):], depth=len(pmapper)) , axis=1)
 seq_one_hot = seq_one_hot /(( seq_shift * 2)+ 1)
 one_hot.append(seq_one_hot)
 for key, depth in ohc:
one_hot.append(tf.one_hot(df[key], depth=depth))
one_hot = tf.concat(one_hot, axis=1)
 dc = dc + df.columns[df.columns.str.contains("P_Seq", na=False)].tolist()
df.drop(dc, axis=1, inplace=True)
 if as_df:
return(df.reset_index(drop=True ).merge(
 pd.DataFrame(one_hot.numpy()), right_index=True, left_index=True))
else:
return tf.concat([df, one_hot], axis=1 )
X_input = Input(( 32, 32, 3))
base_model = DenseNet201(weights=".. /input/pretrained-models/densenet201_weights_tf_dim_ordering_tf_kernels_notop.h5",
include_top=False, input_tensor=X_input)
 model = buildModel(base_model)
 fitModel(model )<train_model>
tf.keras.backend.clear_session()
model = tf.keras.models.Sequential()
model.add(tf.keras.layers.Input(shape=(shape,)))
 model.add(tf.keras.layers.Dense(1, activation='sigmoid'))
model.compile(loss='binary_crossentropy', optimizer='adam', metrics=tf.keras.metrics.AUC())
 hist = model.fit(
 process_flat_df(flat_data.drop("Target", 1),
ohc=[('P_Sub_Class', len(psc_mapper)) ] 
),
flat_data.Target,
validation_split=0.2,
callbacks=tf.keras.callbacks.EarlyStopping(patience=10),
epochs=100,
verbose=0)
 print("Train Best ROC_AUC Score: {:.2f}".format(hist.history['auc'][-1]))
print("Val Best ROC_AUC Score: {:6.2f}".format(hist.history['val_auc'][-1]))
pd.DataFrame(hist.history ).iloc[:, [1, 3]].plot(figsize=(20, 5), title='Model Performance');
X_input = Input(( 32, 32, 3))
base_model = NASNetLarge(weights=".. /input/pretrained-models/NASNet-large-no-top.h5",
include_top=False, input_tensor=X_input)
 model = buildModel(base_model)
 fitModel(model )<define_variables>
predictions = model.predict(
 process_flat_df(
 sub.drop(['Id'], axis=1),
ohc=[('P_Sub_Class', len(psc_mapper)) ])
)
 sub['Expected'] = predictions
sub.head()
epochs = 5
history = []<choose_model_class>
sub[['Id', 'Expected']].to_csv("Linear_model_with_meta.csv", index=False )
learning_rate_reduction = ReduceLROnPlateau(monitor='val_acc', patience=100, verbose=1, \
factor=0.7, min_lr=0.00001 )<choose_model_class>
def get_freq(series, min_thresh=0.65, fit=False):
'Returns a 20 * n matrix containing frequencies for each sequence'
global cnt
if fit:
cnt = CountVectorizer(analyzer='char', ngram_range=(1, 2), min_df=min_thresh, lowercase=False)
 return pd.DataFrame(cnt.fit_transform(series ).todense() , columns=cnt.get_feature_names())
 else:
return pd.DataFrame(cnt.transform(series ).todense() , columns=cnt.get_feature_names())
X_input = Input(( 32, 32, 3))
lrs = [0.00001, 0.00003, 0.0001, 0.0003, 0.001, 0.003, 0.01]
for lr in lrs:
print("=============================")
 print("Fitting model with learning_rate =", lr)
 base_model = VGG19(weights=".. /input/pretrained-models/vgg19_weights_tf_dim_ordering_tf_kernels_notop.h5",
include_top=False, input_tensor=X_input)
 model = buildModel(base_model)
 fitModel(model, lr=lr )<define_variables>
dc=[
'P_Sub_Class',
]
ohc=[ 
('P_Sub_Class', len(psc_mapper)) ,
]
temp = process_flat_df(
 flat_data.drop("Target", 1),
ohc=ohc,
dc=dc,
pep_freq=(data.P_Seq, True),
as_df=True
).head(3)
 shape = temp.shape[1]
temp
epochs = 5
history = []<choose_model_class>
tf.keras.backend.clear_session()
model = tf.keras.models.Sequential()
model.add(tf.keras.layers.Input(shape=(shape,)))
 model.add(tf.keras.layers.Dense(units=1, activation='sigmoid'))
model.compile(loss='binary_crossentropy',
optimizer=tf.keras.optimizers.Adam(0.0025),
metrics=tf.keras.metrics.AUC())
 hist = model.fit(
 process_flat_df(
 flat_data.drop("Target", 1),
ohc=ohc,
dc=dc,
pep_freq=(data.P_Seq, True)
),
flat_data.Target,
batch_size=128,
validation_split=0.2,
callbacks=[
tf.keras.callbacks.EarlyStopping(patience=8, monitor='val_auc', mode='max'),
tf.keras.callbacks.ReduceLROnPlateau(monitor='val_auc', patience=5, factor=0.5, mode='max')],
epochs=100,
verbose=0)
 print("Train Best ROC_AUC Score: {:.2f}".format(hist.history['auc'][-1]))
print("Val Best ROC_AUC Score: {:6.2f}".format(hist.history['val_auc'][-1]))
pd.DataFrame(hist.history ).iloc[:, [1, 3]].plot(figsize=(20, 5), title='Model Performance');
learning_rate_reduction = ReduceLROnPlateau(monitor='val_acc', patience=3, verbose=1, \
factor=0.5, min_lr=1e-5 )<choose_model_class>
predictions = model.predict(
 process_flat_df(
 sub.drop(["Expected", "Id"], 1),
ohc=ohc,
dc=dc,
pep_freq=(test.P_Seq, False)) , 
)
 sub['Expected'] = predictions
sub.head(3 )
X_input = Input(( 32, 32, 3))
frs = [0, 0.25, 0.5, 0.75, 1]
for fr in frs:
print("=============================")
 print("Fitting model with freeze fraction =", fr, "and learning_rate = 1e-4")
 base_model = VGG19(weights=".. /input/pretrained-models/vgg19_weights_tf_dim_ordering_tf_kernels_notop.h5",
include_top=False, input_tensor=X_input)
 model = buildModel(base_model, freeze=fr)
 fitModel(model, lr=1e-4 )<define_search_model>
sub[['Id', 'Expected']].to_csv("Linear_model_with_Seq_freq.csv", index=False )
def buildModel(base_model, freeze=0.8):
threshold = int(len(base_model.layers)* freeze)
 for i in base_model.layers[:threshold]:
i.trainable = False
for i in base_model.layers[threshold:]:
i.trainable = True
X = base_model.output
X = Flatten()(X)
 X = Dense(512, use_bias=True )(X)
 X = BatchNormalization()(X)
 X = Activation('relu' )(X)
 X = Dropout(0.3 )(X)
 X = Dense(256, use_bias=True )(X)
 X = BatchNormalization()(X)
 X = Activation('relu' )(X)
 X = Dropout(0.3 )(X)
 X = Dense(1, activation='sigmoid' )(X)
 model = Model(inputs=base_model.input, outputs=X)
 return model<define_variables>
SHIFT = 2
dc=[
'P_Main_Class',
'Uniq_seq_Count',
]
ohc=[
]
temp = process_flat_df(
 flat_data.drop("Target", 1),
ohc=ohc,
dc=dc,
pep_freq=(data.P_Seq, True),
seq_shift=SHIFT,
as_df=True
).head(5)
 shape = temp.shape[1]
print("The number of columns in data that would be fit to our model is:", shape)
 temp.iloc[:3, 29:29+21]
epochs = 30<train_model>
flat_data['P_Seq'].head(5 ).map(peptide_mapper ).values
X_input = Input(( 32, 32, 3))
base_model = VGG19(weights=".. /input/pretrained-models/vgg19_weights_tf_dim_ordering_tf_kernels_notop.h5",
include_top=False, input_tensor=X_input)
 model = buildModel(base_model, freeze=0.25)
 model = fitModel(model, lr=1e-4, cp=True )<load_from_csv>
SHIFT = 3
tf.keras.backend.clear_session()
model = tf.keras.models.Sequential()
model.add(tf.keras.layers.Input(shape=(shape,)))
 model.add(tf.keras.layers.Dropout(0.1))
model.add(tf.keras.layers.Dense(units=1, activation='sigmoid'))
model.compile(loss='binary_crossentropy',
optimizer=tf.keras.optimizers.Adam(0.005),
metrics=tf.keras.metrics.AUC())
 hist = model.fit(
 process_flat_df(
 flat_data.drop("Target", 1),
ohc=ohc,
dc=dc,
pep_freq=(data.P_Seq, True),
seq_shift=SHIFT),
flat_data.Target,
validation_split=0.25,
batch_size=128,
callbacks=[
tf.keras.callbacks.EarlyStopping(patience=10, monitor='val_auc', mode='max'),
tf.keras.callbacks.ReduceLROnPlateau(monitor='val_auc', patience=5, factor=0.25, mode='max')],
epochs=100,
verbose=0)
 print("Train Best ROC_AUC Score: {:.2f}".format(hist.history['auc'][-1]))
print("Val Best ROC_AUC Score: {:6.2f}".format(hist.history['val_auc'][-1]))
pd.DataFrame(hist.history ).iloc[:, [1, 3]].plot(figsize=(20, 5), title='Model Performance');
submission = test_images = pd.read_csv(".. /input/aerial-cactus-identification/sample_submission.csv")
 submission = pd.DataFrame(test_images.iloc[:, 0], columns=["id"] )<predict_on_test>
predictions = model.predict(
 process_flat_df(
 sub.drop(["Expected", "Id"], 1),
ohc=ohc,
dc=dc,
pep_freq=(test.P_Seq, False)
), 
)
 sub['Expected'] = predictions
sub.head(3 )
<prepare_output><EOS> 
sub[['Id', 'Expected']].to_csv("Linear_model_with_hist.csv", index=False )