Kaggle competition: Titanic - Machine Learning from Disaster
<SOS> metric: categorizationaccuracy Kaggle data source: titanic-machine-learning-from-disaster<save_to_csv>
%matplotlib inline
warnings.filterwarnings(action='ignore', category=DeprecationWarning)
 warnings.filterwarnings(action='ignore', category=FutureWarning )
test_df.to_csv('submission.csv', index = False )<import_modules>
train = pd.read_csv('.. /input/train.csv')
 test = pd.read_csv('.. /input/test.csv' )
print(os.listdir(".. /input"))
seed = 4529
np.random.seed(seed )<load_from_csv>
train = pd.read_csv('.. /input/train.csv')
 test = pd.read_csv('.. /input/test.csv' )
base_dir = os.path.join(".. ", "input")
 train_df = pd.read_csv(os.path.join(base_dir, "train.csv"))
train_dir = os.path.join(base_dir, "train/train")
 test_dir = os.path.join(base_dir, "test/test")
 print(train_df.head() )<set_options>
data = pd.concat([train, test])
 train_size = train.shape[0]
test_size = test.shape[0]
data[train_size-3:train_size+3]
%load_ext tensorboard.notebook
%tensorboard --logdir logs<define_variables>
data['Title'] = data['Name'].str.extract('([A-Za-z]+)\.', expand=False)
 pd.crosstab(data['Title'], data['Pclass'] )
<define_variables>
age_ref = data.groupby('Title' ).Age.mean()
data = data.assign(
 Age = data.apply(lambda r: r.Age if pd.notnull(r.Age)else age_ref[r.Title] , axis=1)
)
 del age_ref
train_df['has_cactus'] = train_df['has_cactus'].astype(str)
 batch_size = 64
train_size = 15750
validation_size = 1750
datagen = ImageDataGenerator(
 rescale=1./255,
horizontal_flip=True,
vertical_flip=False,
brightness_range=(1, 1.3),
shear_range=0.05,
validation_split=0.1)
 data_args = {
"dataframe": train_df,
"directory": train_dir,
"x_col": 'id',
"y_col": 'has_cactus',
"shuffle": True,
"target_size":(32, 32),
"batch_size": batch_size,
"class_mode": 'binary'
}
train_generator = datagen.flow_from_dataframe(**data_args, subset='training')
 validation_generator = datagen.flow_from_dataframe(**data_args, subset='validation' )<choose_model_class>
data['AgeBand'] = pd.cut(data['Age'], 5, labels=range(5)).astype(int)
 data[['AgeBand', 'Survived']].groupby(['AgeBand'] ).agg(['count','mean'] )
model = Sequential([
Conv2D(64,(3,3), padding='same', activation="relu", input_shape=(32, 32, 3)) ,
BatchNormalization() ,
Conv2D(64,(3,3), padding='same', activation="relu"),
BatchNormalization() ,
Conv2D(64,(3,3), padding='same', activation="relu"),
BatchNormalization() ,
MaxPooling2D(2,2),
Dropout(0.4),
Conv2D(128,(3,3), padding='same', activation="relu"),
BatchNormalization() ,
Conv2D(128,(3,3), padding='same', activation="relu"),
BatchNormalization() ,
Conv2D(128,(3,3), padding='same', activation="relu"),
BatchNormalization() ,
MaxPooling2D(2,2),
Dropout(0.4),
Conv2D(256,(3,3), padding='same', activation="relu"),
BatchNormalization() ,
Conv2D(256,(3,3), padding='same', activation="relu"),
BatchNormalization() ,
MaxPooling2D(2,2),
Dropout(0.4),
Conv2D(256,(3,3), padding='same', activation="relu"),
BatchNormalization() ,
Conv2D(256,(3,3), padding='same', activation="relu"),
BatchNormalization() ,
MaxPooling2D(2,2),
Dropout(0.4),
GlobalAveragePooling2D() ,
Dense(units=256, activation='relu'),
Dropout(0.5),
Dense(units=256, activation='relu'),
Dropout(0.5),
Dense(units=1, activation='sigmoid')
 ])
 model.compile(optimizer=Adam(lr=0.001),
loss='binary_crossentropy',
metrics=['acc'])
 model.summary()<choose_model_class>
data['Title'] = data['Title'].replace(['Don', 'Capt', 'Col', 'Major', 'Sir', 'Jonkheer', 'Rev', 'Dr'], 'Honored')
 data['Title'] = data['Title'].replace(['Lady', 'Dona', 'Mme', 'Countess'], 'Mrs')
 data['Title'] = data['Title'].replace(['Mlle', 'Ms'], 'Miss')
 data[['Title', 'Survived']].groupby(['Title'] ).agg(['count','mean'] )
ckpt_path = 'aerial_cactus_detection.hdf5'
earlystop = EarlyStopping(monitor='val_acc', patience=10, verbose=1, restore_best_weights=True)
 reducelr = ReduceLROnPlateau(monitor='val_acc', factor=0.5, patience=3, verbose=1, min_lr=1.e-6)
 modelckpt_cb = ModelCheckpoint(ckpt_path, monitor='val_acc', verbose=1, save_best_only=True, mode='max')
 tb = TensorBoard()
callbacks = [earlystop, reducelr, modelckpt_cb, tb]<train_model>
data['Fare'] = data['Fare'].fillna(13.30 )
history = model.fit_generator(train_generator,
validation_data=validation_generator,
steps_per_epoch=train_size//batch_size,
validation_steps=validation_size//batch_size,
epochs=100, verbose=1,
shuffle=True,
callbacks=callbacks )<load_from_csv>
data['FareBand'] = 0
data.loc[(data.Fare > 0)&(data.Fare <= 7.5), 'FareBand'] = 1
data.loc[(data.Fare > 7.5)&(data.Fare <= 12.5), 'FareBand'] = 2
data.loc[(data.Fare > 12.5)&(data.Fare <= 17), 'FareBand'] = 3
data.loc[(data.Fare > 17)&(data.Fare <= 29), 'FareBand'] = 4
data.loc[data.Fare > 29, 'FareBand'] = 5
data[['FareBand', 'Survived']].groupby(['FareBand'] ).agg(['count','mean'] )
test_df = pd.read_csv(os.path.join(base_dir, "sample_submission.csv"))
print(test_df.head())
 test_images = []
images = test_df['id'].values
for image_id in images:
test_images.append(cv2.imread(os.path.join(test_dir, image_id)))
 test_images = np.asarray(test_images)
 test_images = test_images / 255.0
print("Number of Test set images: " + str(len(test_images)) )<save_to_csv>
data['Embarked'] = data['Embarked'].fillna('S')
 data[['Embarked', 'Survived']].groupby(['Embarked'] ).agg(['count','mean'] )
pred = model.predict(test_images)
 test_df['has_cactus'] = pred
test_df.to_csv('aerial-cactus-submission.csv', index = False )<load_from_csv>
data['DeckCode'] =(data['Cabin'] 
.str.slice(0,1)
.map({
'C':1,
'E':2,
'G':3,
'D':4,
'A':5,
'B':6,
'F':7,
})
.fillna(0)
.astype(int))
data[['DeckCode', 'Survived']].groupby(['DeckCode'] ).agg(['count','mean'] )
train = pd.read_csv('/kaggle/input/google-quest-challenge/train.csv')
 test = pd.read_csv('/kaggle/input/google-quest-challenge/test.csv')
 sample_submission = pd.read_csv('/kaggle/input/google-quest-challenge/sample_submission.csv' )<load_from_csv>
data['Room'] =(data['Cabin'] 
.str.slice(1,5 ).str.extract('([0-9]+)', expand=False)
.fillna(0)
.astype(int))
data['RoomBand'] = 0
data.loc[(data.Room > 0)&(data.Room <= 20), 'RoomBand'] = 1
data.loc[(data.Room > 20)&(data.Room <= 40), 'RoomBand'] = 2
data.loc[(data.Room > 40)&(data.Room <= 80), 'RoomBand'] = 3
data.loc[data.Room > 80, 'RoomBand'] = 4
data[['RoomBand', 'Survived']].groupby(['RoomBand'] ).agg(['count','mean'] )
PATH = '.. /input/google-quest-challenge/'
BERT_PATH = '.. /input/bert-base-uncased-huggingface-transformer/'
tokenizer = BertTokenizer.from_pretrained(BERT_PATH+'bert-base-uncased-vocab.txt')
 MAX_SEQUENCE_LENGTH = 512
df_train = pd.read_csv(PATH+'train.csv')
 df_test = pd.read_csv(PATH+'test.csv')
 df_sub = pd.read_csv(PATH+'sample_submission.csv')
 print('train shape =', df_train.shape)
 print('test shape =', df_test.shape)
 output_categories = list(df_train.columns[11:])
 input_categories = list(df_train.columns[[1,2,5]])
 print('
output categories:
\t', output_categories)
 print('
input categories:
\t', input_categories )<install_modules>
data.loc[data.Ticket=='LINE', 'Ticket'] = 'LINE1'
!pip install.. /input/sacremoses > /dev/null
sys.path.insert(0, ".. /input/transformers/" )<define_variables>
data['Odd'] =(data['Ticket'] 
.str.slice(-1)
.astype(int)
.map(lambda x: x % 2 == 0)
.astype(int)
)
 data[['Odd', 'Survived']].groupby(['Odd'] ).agg(['count','mean'] )
target_cols = ['question_asker_intent_understanding',
'question_body_critical', 'question_conversational',
'question_expect_short_answer', 'question_fact_seeking',
'question_has_commonly_accepted_answer',
'question_interestingness_others', 'question_interestingness_self',
'question_multi_intent', 'question_not_really_a_question',
'question_opinion_seeking', 'question_type_choice',
'question_type_compare', 'question_type_consequence',
'question_type_definition', 'question_type_entity',
'question_type_instructions', 'question_type_procedure',
'question_type_reason_explanation', 'question_type_spelling',
'question_well_written', 'answer_helpful',
'answer_level_of_information', 'answer_plausible', 'answer_relevance',
'answer_satisfaction', 'answer_type_instructions',
'answer_type_procedure', 'answer_type_reason_explanation',
'answer_well_written']<count_missing_values>
data['FamilySize'] =(data['SibSp'] + data['Parch'] ).astype(int)
 data[['FamilySize', 'Survived']].groupby(['FamilySize'] ).agg(['count','mean'] )
train.isna().sum()<count_values>
data[['Sex', 'Survived']].groupby(['Sex'] ).agg(['count','mean'] )
train_category = train['category'].value_counts()
test_category = test['category'].value_counts()<categorify>
data['FamilySizeBand'] = 0
data.loc[(data.FamilySize == 1), 'FamilySizeBand'] = 1
data.loc[(data.FamilySize == 2), 'FamilySizeBand'] = 2
data.loc[(data.FamilySize == 3), 'FamilySizeBand'] = 2
data.loc[data.FamilySize > 3, 'FamilySizeBand'] = 2
data[['FamilySizeBand', 'Survived']].groupby(['FamilySizeBand'] ).agg(['count','mean'] )
def _convert_to_transformer_inputs(title, question, answer, tokenizer, max_sequence_length):

 def return_id(str1, str2, truncation_strategy, length):
inputs = tokenizer.encode_plus(str1, str2,
add_special_tokens=True,
max_length=length,
truncation_strategy=truncation_strategy)
 input_ids = inputs["input_ids"]
input_masks = [1] * len(input_ids)
 input_segments = inputs["token_type_ids"]
padding_length = length - len(input_ids)
 padding_id = tokenizer.pad_token_id
input_ids = input_ids +([padding_id] * padding_length)
 input_masks = input_masks +([0] * padding_length)
 input_segments = input_segments +([0] * padding_length)
 return [input_ids, input_masks, input_segments]
input_ids_q, input_masks_q, input_segments_q = return_id(
 title + ' ' + question, None, 'longest_first', max_sequence_length)
 input_ids_a, input_masks_a, input_segments_a = return_id(
 answer, None, 'longest_first', max_sequence_length)
 return [input_ids_q, input_masks_q, input_segments_q,
input_ids_a, input_masks_a, input_segments_a]
def compute_input_arrays(df, columns, tokenizer, max_sequence_length):
input_ids_q, input_masks_q, input_segments_q = [], [], []
input_ids_a, input_masks_a, input_segments_a = [], [], []
for _, instance in tqdm(df[columns].iterrows()):
t, q, a = instance.question_title, instance.question_body, instance.answer
ids_q, masks_q, segments_q, ids_a, masks_a, segments_a = \
_convert_to_transformer_inputs(t, q, a, tokenizer, max_sequence_length)
 input_ids_q.append(ids_q)
 input_masks_q.append(masks_q)
 input_segments_q.append(segments_q)
 input_ids_a.append(ids_a)
 input_masks_a.append(masks_a)
 input_segments_a.append(segments_a)
 return [np.asarray(input_ids_q, dtype=np.int32),
np.asarray(input_masks_q, dtype=np.int32),
np.asarray(input_segments_q, dtype=np.int32),
np.asarray(input_ids_a, dtype=np.int32),
np.asarray(input_masks_a, dtype=np.int32),
np.asarray(input_segments_a, dtype=np.int32)]
def compute_output_arrays(df, columns):
return np.asarray(df[columns] )<feature_engineering>
data['IsAlone'] =(data['SibSp'] + data['Parch'] == 0 ).astype(int)
 data[['IsAlone', 'Survived']].groupby(['IsAlone'] ).agg(['count','mean'] )
def compute_spearmanr_ignore_nan(trues, preds):
rhos = []
for tcol, pcol in zip(np.transpose(trues), np.transpose(preds)) :
rhos.append(spearmanr(tcol, pcol ).correlation)
 return np.nanmean(rhos)
 def create_model() :
q_id = tf.keras.layers.Input(( MAX_SEQUENCE_LENGTH,), dtype=tf.int32)
 a_id = tf.keras.layers.Input(( MAX_SEQUENCE_LENGTH,), dtype=tf.int32)
 q_mask = tf.keras.layers.Input(( MAX_SEQUENCE_LENGTH,), dtype=tf.int32)
 a_mask = tf.keras.layers.Input(( MAX_SEQUENCE_LENGTH,), dtype=tf.int32)
 q_atn = tf.keras.layers.Input(( MAX_SEQUENCE_LENGTH,), dtype=tf.int32)
 a_atn = tf.keras.layers.Input(( MAX_SEQUENCE_LENGTH,), dtype=tf.int32)
 config = BertConfig()
config.output_hidden_states = False
bert_model = TFBertModel.from_pretrained(
 BERT_PATH+'bert-base-uncased-tf_model.h5', config=config)
 q_embedding = bert_model(q_id, attention_mask=q_mask, token_type_ids=q_atn)[0]
a_embedding = bert_model(a_id, attention_mask=a_mask, token_type_ids=a_atn)[0]
q = tf.keras.layers.GlobalAveragePooling1D()(q_embedding)
 a = tf.keras.layers.GlobalAveragePooling1D()(a_embedding)
 x = tf.keras.layers.Concatenate()([q, a])
 x = tf.keras.layers.Dropout(0.2 )(x)
 x = tf.keras.layers.Dense(30, activation='sigmoid' )(x)
 model = tf.keras.models.Model(inputs=[q_id, q_mask, q_atn, a_id, a_mask, a_atn,], outputs=x)
 return model<categorify>
data['SexCode'] = LabelEncoder().fit_transform(data['Sex'])
 data['TitleCode'] = LabelEncoder().fit_transform(data['Title'])
 data['EmbarkedCode'] = LabelEncoder().fit_transform(data['Embarked'] )
outputs = compute_output_arrays(df_train, output_categories)
 inputs = compute_input_arrays(df_train, input_categories, tokenizer, MAX_SEQUENCE_LENGTH)
 test_inputs = compute_input_arrays(df_test, input_categories, tokenizer, MAX_SEQUENCE_LENGTH )<split>
cols = [
'Pclass',
'Sex',
'FamilySize',
'SibSp',
'Parch',
'IsAlone',
'AgeBand',
'Fare',
'Title',
'DeckCode',
'RoomBand',
]
X_train = data[:train_size][cols]
Y_train = data[:train_size]['Survived'].astype(int)
 X_test = data[train_size:][cols]
print(X_train.shape, Y_train.shape, X_test.shape)
 X_train.head()
gkf = GroupKFold(n_splits=5 ).split(X=df_train.question_body, groups=df_train.question_body)
 valid_preds = []
test_preds = []
for fold,(train_idx, valid_idx)in enumerate(gkf):
if fold in [0, 2]:
train_inputs = [inputs[i][train_idx] for i in range(len(inputs)) ]
train_outputs = outputs[train_idx]
valid_inputs = [inputs[i][valid_idx] for i in range(len(inputs)) ]
valid_outputs = outputs[valid_idx]
K.clear_session()
model = create_model()
optimizer = tf.keras.optimizers.Adam(learning_rate=2e-5)
 model.compile(loss='binary_crossentropy', optimizer=optimizer)
 model.fit(train_inputs, train_outputs, epochs=3, batch_size=6)
 valid_preds.append(model.predict(valid_inputs))
test_preds.append(model.predict(test_inputs))
rho_val = compute_spearmanr_ignore_nan(valid_outputs, valid_preds[-1])
 print('validation score = ', rho_val )<save_to_csv>
one_hot_features = [
'Sex',
'AgeBand',
'Title',
'DeckCode',
'RoomBand',
]
X_train = pd.get_dummies(X_train, columns = one_hot_features)
 X_test = pd.get_dummies(X_test, columns = one_hot_features)
 print(X_train.shape, Y_train.shape, X_test.shape )
df_sub.iloc[:, 1:] = np.average(test_preds, axis=0)
 df_sub.to_csv('submission.csv', index=False )<import_modules>
logreg = LogisticRegression()
logreg.fit(X_train, Y_train)
 logreg.score(X_train, Y_train )
import os
import numpy as np
import pandas as pd
import tensorflow as tf
import tensorflow_hub as th
import matplotlib.pyplot as pl
from pprint import pprint as pp
from six import BytesIO as io
from tqdm import tqdm
from PIL import Image, ImageColor, ImageDraw, ImageFont, ImageOps<categorify>
svc = SVC(C=9)
 svc.fit(X_train, Y_train)
 print(svc.score(X_train, Y_train))
scores = model_selection.cross_val_score(svc, X_train, Y_train, cv=5, scoring='accuracy')
 print(scores)
 print("Kfold on SVC: %0.4f(+/- %0.4f)" %(scores.mean() , scores.std()))
def pred(img_id, rs):
pred_str = []
for i in range(len(rs['detection_scores'])) :
cn = rs['detection_class_names'][i].decode("utf-8")
 YMin,XMin,YMax,XMax = rs['detection_boxes'][i]
sc = rs['detection_scores'][i]
pred_str.append(
 f"{cn} {sc} {XMin} {YMin} {XMax} {YMax}" 
)
 pred_str = " ".join(pred_str)
 return {
"ImageID": img_id,
"PredictionString": pred_str
}
def display_image(image):
fig = pl.figure(figsize =(20, 15))
pl.grid(False)
 pl.axis('off')
 pl.imshow(image )<train_model>
knn = KNeighborsClassifier(n_neighbors=9)
 knn.fit(X_train, Y_train)
 print(knn.score(X_train, Y_train))
scores = model_selection.cross_val_score(knn, X_train, Y_train, cv=5, scoring='accuracy')
 print(scores)
 print("Kfold on KNeighborsClassifier: %0.4f(+/- %0.4f)" %(scores.mean() , scores.std()))
def bound_bx_img(image,
ymin,
xmin,
ymax,
xmax,
color,
font,
thickness = 4,
display_str_list =()):
drw = ImageDraw.Draw(image)
 im_width, im_height = image.size 
(left, right, top, bottom)=(xmin * im_width, xmax * im_width,
ymin * im_height, ymax * im_height)
 drw.line([(left, top),(left, bottom),(right, bottom),(right, top), 
(left, top)],
width = thickness,
fill = color)
 display_str_heights = [font.getsize(ds)[1] for ds in display_str_list]
total_display_str_height =(1 + 2 * 0.05)* sum(display_str_heights)
 if top > total_display_str_height:
txt_bm = top
else:
txt_bm = bottom + total_display_str_height
for display_str in display_str_list[::-1]:
txt_width, txt_height = font.getsize(display_str)
 margin = np.ceil(0.05 * txt_height)
 drw.rectangle([(left, txt_bm - txt_height - 2 * margin), 
(left + txt_width, txt_bm)],
fill = color)
 drw.text(( left + margin, txt_bm - txt_height - margin),
display_str,
fill = "black",
font = font)
 txt_bm -= txt_height - 2 * margin<categorify>
gaussian = GaussianNB()
gaussian.fit(X_train, Y_train)
 gaussian.score(X_train, Y_train )
sm_img_pth = ".. /input/open-images-2019-object-detection/test/4fce161b84175459.jpg"
with tf.Graph().as_default() :
img_str_ph = tf.placeholder(tf.string)
 do_img = tf.image.decode_jpeg(img_str_ph)
 de_img_fl = tf.image.convert_image_dtype(
 image = do_img, dtype = tf.float32 
)
 img_tf = tf.expand_dims(de_img_fl, 0)
 mdl_url = "https://tfhub.dev/google/openimages_v4/ssd/mobilenet_v2/1"
dtr = th.Module(mdl_url)
 dtr_ot = dtr(img_tf, as_dict = True)
 init_ops = [tf.global_variables_initializer() , tf.tables_initializer() ]
ss = tf.Session()
ss.run(init_ops)
 with tf.gfile.Open(sm_img_pth, "rb")as bf :
img_str = bf.read()
rs_ot, img_ot = ss.run(
 [dtr_ot, do_img],
feed_dict = {img_str_ph: img_str}
)<data_type_conversions>
perceptron = Perceptron(max_iter=6)
 perceptron.fit(X_train, Y_train)
 perceptron.score(X_train, Y_train )
img_str_ph = tf.placeholder(tf.string)
 de_img = tf.image.decode_jpeg(img_str_ph)
 de_img_fl = tf.image.convert_image_dtype(
 image = de_img, dtype = tf.float32 
)
 img_ts = tf.expand_dims(de_img_fl, 0 )<feature_engineering>
decision_tree = DecisionTreeClassifier()
decision_tree.fit(X_train, Y_train)
 decision_tree.score(X_train, Y_train )
mdl_url = "https://tfhub.dev/google/openimages_v4/ssd/mobilenet_v2/1"
dc = th.Module(mdl_url)
 dc_ot = dc(img_ts, as_dict = True )<load_pretrained>
sgd = SGDClassifier(max_iter=3)
 sgd.fit(X_train, Y_train)
 sgd.score(X_train, Y_train )
with tf.gfile.Open(sm_img_pth, "rb")as bf :
img_str = bf.read()
rs_ot, img_ot = ss.run(
 [dc_ot, de_img],
feed_dict = {img_str_ph: img_str}
)<load_from_csv>
linear_svc = LinearSVC(C=0.07)
 linear_svc.fit(X_train, Y_train)
 print(linear_svc.score(X_train, Y_train))
scores = model_selection.cross_val_score(linear_svc, X_train, Y_train, cv=5, scoring='accuracy')
 print(scores)
 print("Kfold on LinearSVC: %0.4f(+/- %0.4f)" %(scores.mean() , scores.std()))
sm_sub = pd.read_csv('.. /input/open-images-2019-object-detection/sample_submission.csv')
 img_ids = sm_sub['ImageId']
preds = []
for img_id in tqdm(img_ids):
img_ph = f'.. /input/open-images-2019-object-detection/test/{img_id}.jpg'
with tf.gfile.Open(img_ph, "rb")as bf :
img_str = bf.read()
rs_ot = ss.run(
 dc_ot,
feed_dict = {img_str_ph: img_str} 
)
 preds.append(pred(img_id, rs_ot))
ss.close()<save_to_csv>
rf_params = {
'n_estimators': 700,
'max_depth': 5,
'min_samples_split': 10,
'min_samples_leaf': 1,
'max_features':'auto',
'oob_score':True,
}
random_forest = RandomForestClassifier(**rf_params)
 random_forest.fit(X_train, Y_train)
 print(random_forest.score(X_train, Y_train))
scores = model_selection.cross_val_score(random_forest, X_train, Y_train, cv=5, scoring='accuracy')
 print(scores)
 print("Kfold on RandomForestClassifier: %0.4f(+/- %0.4f)" %(scores.mean() , scores.std()))
submission = pd.DataFrame(preds)
 submission.to_csv('submission.csv', index=False )<load_from_csv>
base_dir='.. /input/'
df1=pd.read_csv(base_dir+'tf-hub-end/'+'submission_75k.csv')
 df1.head()<load_from_csv>
xg_boost = xgb.XGBClassifier(base_score=0.5, booster='gbtree', colsample_bylevel=1,
colsample_bytree=0.65, gamma=2, learning_rate=0.3, max_delta_step=1,
max_depth=4, min_child_weight=2, missing=None, n_estimators=280,
n_jobs=1, nthread=None, objective='binary:logistic', random_state=0,
reg_alpha=0, reg_lambda=1, scale_pos_weight=1, seed=None,
silent=True, subsample=1 )
base_dir='.. /input/'
df2=pd.read_csv(base_dir+'tf-hub-75k/'+'submission_75k.csv')
 df2.head()<load_from_csv>
xg_boost.fit(X_train, Y_train)
 Y_pred = xg_boost.predict(X_test)
 print(xg_boost.score(X_train, Y_train))
scores = model_selection.cross_val_score(xg_boost, X_train, Y_train, cv=5, scoring='accuracy')
 print(scores)
 print("Kfold on XGBClassifier: %0.4f(+/- %0.4f)" %(scores.mean() , scores.std()))
<load_from_csv><EOS> 
submission = pd.DataFrame({
"PassengerId": data[train_size:]["PassengerId"],
"Survived": Y_pred
})
 submission.to_csv('submission.csv', index=False )