Kaggle competition: Titanic - Machine Learning from Disaster
src =(ImageList.from_df(path='train', df=df)
.split_by_rand_pct() 
.label_from_df(cols='label')
 )<normalization>
%matplotlib inline
warnings.filterwarnings('ignore')
 sns.set(style='ticks', context='talk')
 plt.style.use('dark_background' )
data =(src.transform(tfms, size=28)
.databunch(bs=64 ).normalize(imagenet_stats)
 )<define_variables>
DATADIR = '.. /input/titanic/'
train = pd.read_csv('{0}train.csv'.format(DATADIR))
test = pd.read_csv('{0}test.csv'.format(DATADIR))
train_len = len(train)
 IDtest = test['PassengerId']
data.show_batch(rows=3 )<load_pretrained>
dataset = pd.concat(objs=[train, test], axis=0 ).reset_index(drop=True )
!mkdir -p /tmp/.cache/torch/checkpoints
!cp /kaggle/input/fastai-pretrained-models/resnet50-19c8e357.pth /tmp/.cache/torch/checkpoints/resnet50-19c8e357.pth
learn = cnn_learner(data, models.resnet50, metrics=[error_rate, accuracy], model_dir = Path('.. /kaggle/working'),path = Path("."))<find_best_params>
def age_classify(x):
return int(x//10 )
learn.lr_find()<train_model>
dataset['Age'].isnull().sum()
lr = 0.01
learn.fit_one_cycle(4, lr )<save_model>
dataset['n_Age'] = dataset['Age'][dataset['Age'].notnull() ].apply(age_classify )
learn.save('kannada-mnist-stage-1' )<train_model>
dataset['n_Age'].value_counts()
learn.fit_one_cycle(5, slice(1e-4, lr/5))<save_model>
m = len(dataset['n_Age'].value_counts())
 total = dataset['n_Age'].value_counts().sum()
total_null = dataset['n_Age'].isnull().sum()
age_percent = [0]*m
age_dist = [0]*m
for i in range(m):
age_percent[i]=round(( dataset['n_Age'].value_counts() [i]/total),3)
 age_dist[i] = int(round(age_percent[i]*total_null))
age_dist[3]-=1
print('percentage[%] : ',np.multiply(age_percent,100))
print('counts for n_Age :',age_dist)
learn.save('kanada-mnist-stage-2' )<load_pretrained>
total_null = dataset['n_Age'].isnull().sum()
for i in dataset['n_Age'].index[dataset['n_Age'].isnull() ]:
if age_dist[0] != 0:
dataset['n_Age'][i]=0.0
age_dist[0]-=1
elif age_dist[1] != 0:
dataset['n_Age'][i]=1.0
age_dist[1]-=1
elif age_dist[2] != 0:
dataset['n_Age'][i]=2.0
age_dist[2]-=1
elif age_dist[3] != 0:
dataset['n_Age'][i]=3.0
age_dist[3]-=1
elif age_dist[4] != 0:
dataset['n_Age'][i]=4.0
age_dist[4]-=1
elif age_dist[5] != 0:
dataset['n_Age'][i]=5.0
age_dist[5]-=1
elif age_dist[6] != 0:
dataset['n_Age'][i]=6.0
age_dist[6]-=1
elif age_dist[7] != 0:
dataset['n_Age'][i]=7.0
age_dist[7]-=1
elif age_dist[8] != 0:
dataset['n_Age'][i]=8.0
age_dist[8]-=1
dataframes = []
test = ImageList.from_df(path='test', df=df_test)
 learn = load_learner(path="/kaggle/working/", test=test)
 preds, _ = learn.get_preds(ds_type=DatasetType.Test )<prepare_output>
dataset['n_Age'].isnull().sum()
output= preds.argmax(dim=1 )<prepare_output>
dataset.drop(labels=['Age'], axis=1, inplace=True )
df_sub = test_id<feature_engineering>
dataset['Sex'].value_counts()
df_sub['label'] = pd.Series(output )<train_model>
dataset['SibSp'].value_counts()
!rm -rf train<save_to_csv>
dataset['Parch'].value_counts()
df_sub.to_csv(path_or_buf ="submission.csv", index=False )<import_modules>
dataset['FamSize']=dataset['SibSp']+dataset['Parch']+1
import tensorflow as tf
from sklearn.model_selection import train_test_split
import keras
from tensorflow.keras.optimizers import RMSprop
from tensorflow.keras.preprocessing.image import ImageDataGenerator
from keras.layers import LeakyReLU
from keras.layers.normalization import BatchNormalization
from tensorflow.keras.callbacks import LearningRateScheduler
from tensorflow.keras.callbacks import EarlyStopping
import matplotlib.pyplot as plt<load_from_csv>
dataset['FamSize'].isnull().sum()
train = pd.read_csv('/kaggle/input/Kannada-MNIST/train.csv')
 test = pd.read_csv("/kaggle/input/Kannada-MNIST/test.csv")
 Dig_MNIST = pd.read_csv("/kaggle/input/Kannada-MNIST/Dig-MNIST.csv" )<load_from_csv>
dataset['FamSize'].value_counts()
sample_sub = pd.read_csv("/kaggle/input/Kannada-MNIST/sample_submission.csv" )<prepare_x_and_y>
dataset.drop(labels=['SibSp','Parch'], axis=1, inplace=True )
X=train.iloc[:,1:].values
Y=train.iloc[:,0].values
Y[:10]<split>
dataset['Name'].isnull().sum()
X_train, X_valid, Y_train, Y_valid = train_test_split(X, Y, test_size = 0.10, random_state=42 )<choose_model_class>
dataset['Title'] = [0]*dataset['Name'].shape[0]
train_datagen = ImageDataGenerator(rescale = 1./255.,
rotation_range = 10,
width_shift_range = 0.25,
height_shift_range = 0.25,
shear_range = 0.1,
zoom_range = 0.25,
horizontal_flip = False )<define_variables>
num=0
for x in dataset['Name']:
title = x.split(',')[1].split(',')[0].split('.')[0]
title = title.split(' ')[1]
dataset['Title'][num]=title
num+=1
valid_datagen = ImageDataGenerator(rescale=1./255 )<normalization>
dataset['Title'].value_counts()
def lr_decay(epoch):
return initial_learningrate * 0.99 ** epoch<choose_model_class>
dataset['Title'].replace(['Rev','Dr','Col','Major','Jonkheer','Ms','Mlle','Mme','Lady','Dona','the Countess','Sir','Capt','Don'],'Rare', inplace=True)
 dataset['Title'] = dataset['Title'].replace(['Ms','Mlle','Mme','Lady','Dona','the'],'Miss')
 dataset['Title'] = dataset['Title'].replace(['Sir','Capt','Don'],'Mr')
 dataset['Title'].unique()
model = tf.keras.models.Sequential([
tf.keras.layers.Conv2D(filters=64, kernel_size=(3,3), padding='same', input_shape=(28, 28, 1)) ,
tf.keras.layers.BatchNormalization(momentum=0.5, epsilon=1e-5, gamma_initializer="uniform"),
tf.keras.layers.LeakyReLU(alpha=0.1),
tf.keras.layers.Conv2D(filters=64, kernel_size=(3,3), padding='same'),
tf.keras.layers.BatchNormalization(momentum=0.1, epsilon=1e-5, gamma_initializer="uniform"),
tf.keras.layers.LeakyReLU(alpha=0.1),
tf.keras.layers.MaxPooling2D(2, 2),
tf.keras.layers.Dropout(0.2),
tf.keras.layers.Conv2D(filters=128, kernel_size=(3,3), padding='same'),
tf.keras.layers.BatchNormalization(momentum=0.2, epsilon=1e-5, gamma_initializer="uniform"),
tf.keras.layers.LeakyReLU(alpha=0.1),
tf.keras.layers.Conv2D(filters=128, kernel_size=(3,3), padding='same'),
tf.keras.layers.BatchNormalization(momentum=0.1, epsilon=1e-5, gamma_initializer="uniform"),
tf.keras.layers.LeakyReLU(alpha=0.1),
tf.keras.layers.MaxPooling2D(2,2),
tf.keras.layers.Dropout(0.2),
tf.keras.layers.Conv2D(filters=256, kernel_size=(3,3), padding='same'),
tf.keras.layers.BatchNormalization(momentum=0.2, epsilon=1e-5, gamma_initializer="uniform"),
tf.keras.layers.LeakyReLU(alpha=0.1),
tf.keras.layers.Conv2D(filters=256, kernel_size=(3,3), padding='same'),
tf.keras.layers.BatchNormalization(momentum=0.1, epsilon=1e-5, gamma_initializer="uniform"),
tf.keras.layers.LeakyReLU(alpha=0.1),
tf.keras.layers.MaxPooling2D(2,2),
tf.keras.layers.Dropout(0.2),
tf.keras.layers.Flatten() ,
tf.keras.layers.Dense(256),
tf.keras.layers.LeakyReLU(alpha=0.1),
tf.keras.layers.BatchNormalization() ,
tf.keras.layers.Dense(10, activation='softmax')
 ])
 model.summary() 
<choose_model_class>
dataset.drop(labels=['Name'], axis=1, inplace=True)
 dataset.head()
initial_learningrate=2e-3
batch_size = 1024
epochs = 30
input_shape =(28, 28, 1)
 model.compile(loss="categorical_crossentropy",
optimizer=RMSprop(lr=initial_learningrate),
metrics=['accuracy'])
 learning_rate_reduction = ReduceLROnPlateau(monitor='loss',
patience=2,
verbose=1,
factor=0.2,
min_lr=0.00001)
 history = model.fit_generator(
 train_datagen.flow(X_train,Y_train, batch_size=batch_size),
steps_per_epoch=100,
epochs=epochs,
callbacks=[learning_rate_reduction],
validation_data=valid_datagen.flow(X_valid,Y_valid),
validation_steps=50
)<compute_train_metric>
dataset['Embarked'].value_counts()
preds_dig=model.predict_classes(x_dig/255)
 metrics.accuracy_score(preds_dig, y_dig )<predict_on_test>
dataset['Embarked'].fillna(method='ffill', inplace = True )
predictions = model.predict_classes(x_test/255.)<save_to_csv>
dataset['Embarked'].isnull().sum()
submission = pd.read_csv('.. /input/Kannada-MNIST/sample_submission.csv')
 submission['label'] = predictions
submission.to_csv("submission.csv",index=False )<import_modules>
dataset['Fare'].fillna(method='ffill',inplace=True )
import numpy as np
import pandas as pd 
<set_options>
dataset['Fare'].isnull().sum()
config = tf.ConfigProto()
config.gpu_options.allow_growth = True
tf.keras.backend.set_session(tf.Session(config=config)) 
<import_modules>
dataset['n_Fare'] =(dataset['Fare']//1.0 )
from keras.layers import LeakyReLU
from keras.layers.normalization import BatchNormalization<load_from_csv>
dataset['n_Fare'].isnull().sum()
train = pd.read_csv('/kaggle/input/Kannada-MNIST/train.csv')
 test = pd.read_csv('/kaggle/input/Kannada-MNIST/test.csv')
 sample_sub = pd.read_csv('/kaggle/input/Kannada-MNIST/sample_submission.csv')
 dig = pd.read_csv('/kaggle/input/Kannada-MNIST/Dig-MNIST.csv' )<split>
dataset['n_Fare'] = pd.qcut(dataset['n_Fare'], 7 )
x_train = train.values[:,1:].reshape(train.shape[0], 28, 28, 1)
 x_train = x_train.astype('float32')
 x_train = x_train / 255.0
y_train = train.values[:,0]
x_train, x_valid, y_train, y_valid = train_test_split(x_train, y_train, test_size = 0.1, random_state=2019)
 x_test = test.values[:,1:].reshape(test.shape[0], 28, 28, 1)
 x_test = x_test.astype('float32')
 x_test = x_test / 255.0<categorify>
def mapping(x):
x= str(x)
 left=(x.split(', ')[0].split('(')[1])
 if left =='-0.001': return 1
elif left =='7.0' : return 2
elif left =='8.0' : return 3
elif left =='12.0' : return 4
elif left =='19.0' : return 5
elif left =='27.0' : return 6
elif left =='59.0' : return 7
lb = preprocessing.LabelBinarizer()
y_train = lb.fit_transform(y_train)
 y_valid = lb.fit_transform(y_valid )<choose_model_class>
dataset['n_Fare'] = dataset['n_Fare'].map(mapping)
 dataset['n_Fare'].astype(int )
modelo = Sequential()
modelo.add(Conv2D(64,(3,3), padding='same', input_shape=(28, 28, 1)))
 modelo.add(BatchNormalization(momentum=0.5, epsilon=1e-5, gamma_initializer="uniform"))
modelo.add(LeakyReLU(alpha=0.1))
modelo.add(Conv2D(128,(3,3), padding='same'))
modelo.add(BatchNormalization(momentum=0.1, epsilon=1e-5, gamma_initializer="uniform"))
modelo.add(LeakyReLU(alpha=0.1))
modelo.add(MaxPooling2D(2, 2))
modelo.add(Dropout(0.2))
modelo.add(Conv2D(128,(3,3), padding='same'))
modelo.add(BatchNormalization(momentum=0.2, epsilon=1e-5, gamma_initializer="uniform"))
modelo.add(LeakyReLU(alpha=0.1))
modelo.add(Conv2D(256,(3,3), padding='same'))
modelo.add(BatchNormalization(momentum=0.1, epsilon=1e-5, gamma_initializer="uniform"))
modelo.add(LeakyReLU(alpha=0.1))
modelo.add(MaxPooling2D(2, 2))
modelo.add(Dropout(0.2))
modelo.add(Conv2D(256,(3,3), padding='same'))
modelo.add(BatchNormalization(momentum=0.2, epsilon=1e-5, gamma_initializer="uniform"))
modelo.add(LeakyReLU(alpha=0.1))
modelo.add(Conv2D(256,(3,3), padding='same'))
modelo.add(BatchNormalization(momentum=0.1, epsilon=1e-5, gamma_initializer="uniform"))
modelo.add(LeakyReLU(alpha=0.1))
modelo.add(MaxPooling2D(2,2))
modelo.add(Dropout(0.2))
modelo.add(Flatten())
 modelo.add(Dense(256))
modelo.add(LeakyReLU(alpha=0.1))
modelo.add(BatchNormalization())
 modelo.add(Dense(10, activation='softmax'))<train_model>
dataset['n_Fare'].value_counts()
epochs=50
batch_size=200
history = modelo.fit(x_train, y_train,
epochs=epochs,
batch_size= batch_size,
validation_data=(x_valid, y_valid))<predict_on_test>
dataset.drop(labels=['Fare', 'PassengerId'],axis=1, inplace=True )
scores = modelo.predict(x_test)
 score_classes = np.argmax(scores, axis = 1)
 x_dig=dig.drop('label',axis=1 ).iloc[:,:].values
print(x_dig.shape)
 x_dig = x_dig.reshape(x_dig.shape[0], 28, 28,1)
 print(x_dig.shape)
 y_dig=dig.label
print(y_dig.shape)
 preds_dig=modelo.predict_classes(x_dig/255)
 metrics.accuracy_score(preds_dig, y_dig )<prepare_output>
dataset['Pclass'].value_counts()
output = pd.DataFrame({'id': sample_sub['id'],
'label': score_classes})
 output.head()<save_to_csv>
dataset['Pclass'].isnull().sum()
output.to_csv('submission.csv', index=False )<set_options>
dataset['Cabin'].value_counts()
%matplotlib inline 
<load_from_csv>
dataset['n_Cabin'] = dataset['Cabin'].apply(refine )
train = pd.read_csv('/kaggle/input/Kannada-MNIST/train.csv')
 test = pd.read_csv("/kaggle/input/Kannada-MNIST/test.csv")
 Dig_MNIST = pd.read_csv("/kaggle/input/Kannada-MNIST/Dig-MNIST.csv" )<load_from_csv>
dataset['n_Cabin']=dataset['n_Cabin'].map({'A':2,'B':1,'C':3,'D':1,'E':1,'F':3,'G':2,'T':1,'X':4} )
sample_sub = pd.read_csv("/kaggle/input/Kannada-MNIST/sample_submission.csv" )<prepare_x_and_y>
dataset.drop(labels=['Cabin'], axis=1, inplace=True )
X=train.iloc[:,1:].values
Y=train.iloc[:,0].values
Y[:10]<split>
dataset['Ticket'].value_counts()
X_train, X_valid, Y_train, Y_valid = train_test_split(X, Y, test_size = 0.10, random_state=42 )<choose_model_class>
dataset['Ticket_Frequency'] = dataset.groupby('Ticket')['Ticket'].transform('count' )
train_datagen = ImageDataGenerator(rescale = 1./255.,
rotation_range = 10,
width_shift_range = 0.25,
height_shift_range = 0.25,
shear_range = 0.1,
zoom_range = 0.25,
horizontal_flip = False )<define_variables>
dataset = dataset.drop(labels=['Ticket'],axis=1 )
valid_datagen = ImageDataGenerator(rescale=1./255 )<normalization>
dataset = pd.get_dummies(dataset, columns=[ 'Sex' ], prefix='Sx')
 dataset = pd.get_dummies(dataset, columns=[ 'Embarked'], prefix='Em')
 dataset = pd.get_dummies(dataset, columns=[ 'Title' ], prefix='Tt')
 dataset = pd.get_dummies(dataset, columns=[ 'n_Fare' ], prefix='nF')
def lr_decay(epoch):
return initial_learningrate * 0.99 ** epoch<choose_model_class>
es = EarlyStopping(monitor='val_loss', verbose=1, patience=10 )<import_modules>
train = dataset[:train_len]
test = dataset[train_len:]
test.drop(labels=['Survived'], axis=1, inplace=True )
from sklearn import metrics 
<choose_model_class>
train['Survived'] = train['Survived'].astype(int)
 Y_train = train['Survived']
X_train = train.drop(labels=['Survived'], axis=1 )
model = Sequential([
Conv2D(64,(3,3), padding='same', input_shape=(28, 28, 1)) ,
BatchNormalization(momentum=0.5, epsilon=1e-5, gamma_initializer="uniform"),
LeakyReLU(alpha=0.1),
Conv2D(64,(3,3), padding='same'),
BatchNormalization(momentum=0.1, epsilon=1e-5, gamma_initializer="uniform"),
LeakyReLU(alpha=0.1),
layers.MaxPooling2D(2, 2),
Dropout(0.2),
Conv2D(128,(3,3), padding='same'),
BatchNormalization(momentum=0.2, epsilon=1e-5, gamma_initializer="uniform"),
LeakyReLU(alpha=0.1),
Conv2D(128,(3,3), padding='same'),
BatchNormalization(momentum=0.1, epsilon=1e-5, gamma_initializer="uniform"),
LeakyReLU(alpha=0.1),
layers.MaxPooling2D(2,2),
Dropout(0.2),
Conv2D(256,(3,3), padding='same'),
BatchNormalization(momentum=0.2, epsilon=1e-5, gamma_initializer="uniform"),
LeakyReLU(alpha=0.1),
Conv2D(256,(3,3), padding='same'),
BatchNormalization(momentum=0.1, epsilon=1e-5, gamma_initializer="uniform"),
LeakyReLU(alpha=0.1),
layers.MaxPooling2D(2,2),
Dropout(0.2),
Flatten() ,
Dense(256),
LeakyReLU(alpha=0.1),
BatchNormalization() ,
Dense(10, activation='softmax')
 ])
 model.summary()<define_variables>
kfold = StratifiedKFold(n_splits=10 )
initial_learningrate=2e-3
batch_size = 1024
epochs = 50
input_shape =(28, 28, 1 )<choose_model_class>
random_state=3
classifiers = []
classifiers.append(SVC(random_state=random_state))
classifiers.append(DecisionTreeClassifier(random_state=random_state))
classifiers.append(AdaBoostClassifier(DecisionTreeClassifier(random_state=random_state), random_state=random_state, learning_rate=0.1))
classifiers.append(RandomForestClassifier(random_state=random_state))
classifiers.append(ExtraTreesClassifier(random_state=random_state))
classifiers.append(GradientBoostingClassifier(random_state=random_state))
classifiers.append(MLPClassifier(random_state=random_state))
classifiers.append(KNeighborsClassifier())
 classifiers.append(LogisticRegression(random_state=random_state))
classifiers.append(LinearDiscriminantAnalysis())
 classifiers.append(XGBClassifier(random_state=random_state))
model.compile(loss="categorical_crossentropy",
optimizer=RMSprop(lr=initial_learningrate),
metrics=['accuracy'] )<train_model>
XGB = XGBClassifier(random_state=0)
 xgb_param_grid={'colsample_bylevel':[0.9],
'colsample_bytree' :[0.8],
'gamma' :[0.99],
'max_depth' :[4],
'min_child_weight' :[1],
'n_estimators' :[10],
'nthread' :[4],
'silent' :[True]}
gsXGB = GridSearchCV(XGB, param_grid=xgb_param_grid, cv=kfold, scoring='accuracy', n_jobs=4, verbose=1)
 gsXGB.fit(X_train, Y_train)
 XGBC_best = gsXGB.best_estimator_
gsXGB.best_score_
history = model.fit_generator(
 train_datagen.flow(X,Y, batch_size=batch_size),
steps_per_epoch=100,
epochs=epochs,
callbacks=[LearningRateScheduler(lr_decay)
 ],
validation_data=valid_datagen.flow(X_valid,Y_valid),
validation_steps=50,
verbose=2 )<compute_train_metric>
DTC = DecisionTreeClassifier(max_depth=1)
 adaDTC = AdaBoostClassifier(DTC, random_state=0)
 ada_param_grid = {'base_estimator__criterion':['gini', 'entropy'],
'base_estimator__splitter' :['best', 'random'],
'algorithm' :['SAMME', 'SAMME.R'],
'n_estimators' :[100],
'learning_rate' :[0.0001, 0.001, 0.01, 0.1, 1, 5, 10]}
gsadaDTC = GridSearchCV(adaDTC, param_grid=ada_param_grid, cv=kfold, scoring='accuracy', n_jobs=4, verbose=1)
 gsadaDTC.fit(X_train,Y_train)
 ada_best = gsadaDTC.best_estimator_
gsadaDTC.best_score_
preds_dig=model.predict_classes(x_dig/255)
 metrics.accuracy_score(preds_dig, y_dig )<predict_on_test>
ExtC = ExtraTreesClassifier(random_state=0)
 ex_param_grid = {'max_depth' :[4],
'max_features' :[7],
'min_samples_split':[8],
'min_samples_leaf' :[4],
'bootstrap' :[False],
'n_estimators' :[100],
'criterion' :['gini']}
gsExtC = GridSearchCV(ExtC, param_grid=ex_param_grid, cv=kfold, scoring='accuracy', n_jobs=4, verbose=1)
 gsExtC.fit(X_train, Y_train)
 ExtC_best = gsExtC.best_estimator_
gsExtC.best_score_
predictions = model.predict_classes(x_test/255.)<load_from_csv>
RFC = RandomForestClassifier(random_state=0)
 rf_param_grid = {'max_depth' :[6],
'max_features' :[10],
'min_samples_split':[10],
'bootstrap' :[False],
'n_estimators' :[100],
'criterion' :['gini']}
gsRFC = GridSearchCV(RFC, param_grid=rf_param_grid, cv=kfold, scoring='accuracy', n_jobs=4, verbose=1)
 gsRFC.fit(X_train, Y_train)
 RFC_best = gsRFC.best_estimator_
gsRFC.best_score_
submission = pd.read_csv('.. /input/Kannada-MNIST/sample_submission.csv' )<prepare_output>
GBC = GradientBoostingClassifier(random_state=0)
 gb_param_grid = {'loss' :['deviance'],
'n_estimators' :[10],
'learning_rate' :[0.001, 0.01, 0.1, 1, 10, 100],
'max_depth' :[4],
'min_samples_leaf':[8],
'max_features' :[0.3, 0.1]
}
gsGBC = GridSearchCV(GBC, param_grid=gb_param_grid, cv=kfold, scoring='accuracy',n_jobs=4, verbose=1)
 gsGBC.fit(X_train, Y_train)
 GBC_best = gsGBC.best_estimator_
gsGBC.best_score_
submission['label'] = predictions<save_to_csv>
SVMC = SVC(probability=True)
 svc_param_grid = {'kernel':['rbf'],
'gamma' :[0.01,0.1,1,10,100],
'C' :[0.01,0.1,1,10,100]}
gsSVMC = GridSearchCV(SVMC, param_grid=svc_param_grid, cv=kfold, scoring='accuracy', n_jobs=4, verbose=1)
 gsSVMC.fit(X_train, Y_train)
 SVMC_best = gsSVMC.best_estimator_
gsSVMC.best_score_
submission.to_csv("submission.csv",index=False )<import_modules>
parameters = {'solver':['adam'], 'max_iter':[800], 'alpha':10.0**-np.arange(1,10), 'hidden_layer_sizes':[40,20,10], 'random_state':[0,1] }
gsMLPC=GridSearchCV(MLPClassifier() , parameters, n_jobs=-1)
 gsMLPC.fit(X_train, Y_train)
 MLPC_best = gsMLPC.best_estimator_
gsMLPC.best_score_
from keras.utils import to_categorical
from keras.models import Sequential
from keras.layers import Dense, Dropout, Flatten, Conv2D, MaxPool2D
from keras.optimizers import RMSprop,Adam
from keras.preprocessing.image import ImageDataGenerator<import_modules>
test_Survived = gsExtC.predict(test)
 submission = pd.DataFrame({
'PassengerId' : IDtest,
'Survived' : test_Survived
})
 submission.to_csv('ExtC_55th.csv', index=False )
from sklearn.model_selection import train_test_split<import_modules>
test_Survived = gsXGB.predict(test)
 submission = pd.DataFrame({
'PassengerId' : IDtest,
'Survived' : test_Survived
})
 submission.to_csv('XGB_55th.csv', index=False )
from sklearn.model_selection import train_test_split<define_variables>
test_Survived = gsGBC.predict(test)
 submission = pd.DataFrame({
'PassengerId' : IDtest,
'Survived' : test_Survived
})
 submission.to_csv('GBC_55th.csv', index=False )
<load_from_csv><EOS> 
test_Survived = gsSVMC.predict(test)
 submission = pd.DataFrame({
'PassengerId' : IDtest,
'Survived' : test_Survived
})
 submission.to_csv('SVMC_55th.csv', index=False )