Kaggle competition: PUBG Finish Placement Prediction (Kernels Only)
model = Sequential()
model.add(Conv2D(filters=32, kernel_size=(5,5), padding='same', activation='relu', input_shape=(28, 28, 1)))
 model.add(MaxPool2D(pool_size = 2,strides=2))
model.add(Conv2D(filters=48, kernel_size=(5,5), padding='valid', activation='relu'))
model.add(MaxPool2D(pool_size = 2,strides=2))
model.add(Flatten())
 model.add(Dense(120, activation='relu'))
model.add(Dense(84, activation='relu'))
model.add(Dense(10, activation='softmax'))
adam = Adam(lr=5e-4)
 model.compile(loss='categorical_crossentropy', metrics=['accuracy'], optimizer=adam )<choose_model_class>
train = pd.read_csv('.. /input/train_V2.csv')
 train.head(10 )
reduce_lr = ReduceLROnPlateau(monitor='val_acc',
patience=3,
verbose=1,
factor=0.2,
min_lr=1e-6 )<train_model>
datagen = ImageDataGenerator(
 rotation_range=10,
width_shift_range=0.1,
height_shift_range=0.1,
zoom_range=0.1)
 history = datagen.fit(X_train )<train_model>
test = pd.read_csv('.. /input/test_V2.csv')
history = model.fit_generator(datagen.flow(X_train, Y_train, batch_size=100), steps_per_epoch=len(X_train)/100,
epochs=20, validation_data=(X_test, Y_test), callbacks=[reduce_lr] )<train_model>
train_matchtype = pd.get_dummies(train['matchType'] )
<compute_test_metric>
test_matchtype = pd.get_dummies(test['matchType'] )
score = model.evaluate(X_test, Y_test, verbose=0)
 print('Test loss:', score[0])
 print('Test accuracy:', score[1] )<load_from_csv>
for i in ['assists', 'boosts', 'damageDealt', 'DBNOs',
'headshotKills', 'heals', 'killPlace', 'killPoints', 'kills',
'killStreaks', 'longestKill', 'matchDuration', 'maxPlace',
'numGroups', 'rankPoints', 'revives', 'rideDistance', 'roadKills',
'swimDistance', 'teamKills', 'vehicleDestroys', 'walkDistance',
'weaponsAcquired', 'winPoints']:
a='std'+i
print(a)
 test[a] = test.groupby(['groupId'])[i].transform('std')
 train[a] = train.groupby(['groupId'])[i].transform('std')
 test[a] = test[a].fillna(0)
 train[a] = train[a].fillna(0)
test_data = pd.read_csv('/kaggle/input/digit-recognizer/test.csv' )<data_type_conversions>
for i in ['assists', 'boosts', 'damageDealt', 'DBNOs',
'headshotKills', 'heals', 'killPlace', 'killPoints', 'kills',
'killStreaks', 'longestKill', 'matchDuration', 'maxPlace',
'numGroups', 'rankPoints', 'revives', 'rideDistance', 'roadKills',
'swimDistance', 'teamKills', 'vehicleDestroys', 'walkDistance',
'weaponsAcquired', 'winPoints']:
a='Mean'+i
print(a)
 test[a] = test.groupby(['groupId'])[i].transform('mean')
 train[a] = train.groupby(['groupId'])[i].transform('mean')
 test[a] = test[a].fillna(0)
 train[a] = train[a].fillna(0)
test_data = test_data.values
test_data = test_data.reshape(28000, 28, 28,1)
 test_data = test_data.astype('float32')
 test_data /= 255
print("Test data matrix shape", test_data.shape )<predict_on_test>
train=train.fillna(0 )
y_pred = model.predict_classes(test_data, verbose=0)
 print(y_pred )<predict_on_test>
for i in ['assists', 'boosts', 'damageDealt', 'DBNOs','matchType',
'headshotKills', 'heals', 'killPlace', 'killPoints', 'kills',
'killStreaks', 'longestKill', 'matchDuration', 'maxPlace',
'numGroups', 'rankPoints', 'revives', 'rideDistance', 'roadKills',
'swimDistance', 'teamKills', 'vehicleDestroys', 'walkDistance',
'weaponsAcquired', 'winPoints']:
print(i)
 train=train.drop(columns=i)
 test=test.drop(columns=i )
i = 9713
predicted_value = np.argmax(model.predict(X_test[i].reshape(1,28, 28,1)))
 print('predicted value:',predicted_value)
 plt.imshow(X_test[i].reshape([28, 28]), cmap='Greys_r' )<save_to_csv>
train['NumberOfPlayers'] = train.groupby('matchId')['matchId'].transform('count')
 train['NumberOfPlayersInTeam'] = train.groupby(['matchId','groupId'])['groupId'].transform('count' )
submissions=pd.DataFrame({"ImageId": list(range(1,len(y_pred)+1)) ,
"Label": y_pred})
 submissions.to_csv("LeNet_CNN.csv", index=False )<install_modules>
test['NumberOfPlayers'] = test.groupby('matchId')['matchId'].transform('count')
 test['NumberOfPlayersInTeam'] = test.groupby(['matchId','groupId'])['groupId'].transform('count' )
!pip install emnist<import_modules>
train = pd.concat([train,train_matchtype],axis=1 )
import matplotlib.pyplot as plt,seaborn as sns,pandas as pd,numpy as np
from keras.models import Sequential, load_model
from keras.layers.core import Dense, Dropout, Activation
from keras.layers import Conv2D, MaxPooling2D,MaxPool2D,Flatten,BatchNormalization
from keras.utils import np_utils
from keras.preprocessing.image import ImageDataGenerator
from keras.callbacks import ReduceLROnPlateau
from emnist import extract_training_samples
from emnist import extract_test_samples
from keras.optimizers import Adam<prepare_x_and_y>
test = pd.concat([test,test_matchtype],axis=1 )
x_train, y_train = extract_training_samples('digits')
 x_test, y_test = extract_test_samples('digits' )<load_from_csv>
traing= train.drop_duplicates(subset=['groupId'], keep='first')
 del train
in_train_data = pd.read_csv('/kaggle/input/digit-recognizer/train.csv')
 ex_y_train = in_train_data["label"]
ex_x_train = in_train_data.drop(labels = ["label"],axis = 1 )<prepare_x_and_y>
testg= test.drop_duplicates(subset=['groupId'], keep='first')
X_train = x_train.reshape(240000, 28, 28,1)
 X_test = x_test.reshape(40000, 28, 28,1)
 ex_x_train = ex_x_train.values.reshape(42000,28,28,1)
 X_train = np.vstack(( X_train, ex_x_train))
print(X_train.shape )<data_type_conversions>
traing['NumberOfGroups'] = traing.groupby('matchId')['groupId'].transform('count')
X_train = X_train.astype('float32')
 X_test = X_test.astype('float32' )<categorify>
testg['NumberOfGroups'] = testg.groupby('matchId')['groupId'].transform('count')
X_train /= 255
X_test /= 255<concatenate>
Y=traing["winPlacePerc"]
traing=traing.drop(columns="winPlacePerc")
 train_objs_num = len(traing)
y_train = np.concatenate([y_train,ex_y_train.values])
 print(y_train.shape )<categorify>
for i in ['stdassists', 'stdboosts', 'stddamageDealt',
'stdDBNOs', 'stdheadshotKills', 'stdheals', 'stdkillPlace',
'stdkillPoints', 'stdkills', 'stdkillStreaks', 'stdlongestKill',
'stdmatchDuration', 'stdmaxPlace', 'stdnumGroups', 'stdrankPoints',
'stdrevives', 'stdrideDistance', 'stdroadKills', 'stdswimDistance',
'stdteamKills', 'stdvehicleDestroys', 'stdwalkDistance',
'stdweaponsAcquired', 'stdwinPoints', 'Meanassists', 'Meanboosts',
'MeandamageDealt', 'MeanDBNOs', 'MeanheadshotKills', 'Meanheals',
'MeankillPlace', 'MeankillPoints', 'Meankills', 'MeankillStreaks',
'MeanlongestKill', 'MeanmatchDuration', 'MeanmaxPlace', 'MeannumGroups',
'MeanrankPoints', 'Meanrevives', 'MeanrideDistance', 'MeanroadKills',
'MeanswimDistance', 'MeanteamKills', 'MeanvehicleDestroys',
'MeanwalkDistance', 'MeanweaponsAcquired', 'MeanwinPoints',
]:
a='std2'+i
print(a)
 testg[a] = testg.groupby(['matchId'])[i].transform('std')
 traing[a] = traing.groupby(['matchId'])[i].transform('std')
 testg[a] = testg[a].fillna(0)
 traing[a] = traing[a].fillna(0)
 for i in ['stdassists', 'stdboosts', 'stddamageDealt',
'stdDBNOs', 'stdheadshotKills', 'stdheals', 'stdkillPlace',
'stdkillPoints', 'stdkills', 'stdkillStreaks', 'stdlongestKill',
'stdmatchDuration', 'stdmaxPlace', 'stdnumGroups', 'stdrankPoints',
'stdrevives', 'stdrideDistance', 'stdroadKills', 'stdswimDistance',
'stdteamKills', 'stdvehicleDestroys', 'stdwalkDistance',
'stdweaponsAcquired', 'stdwinPoints', 'Meanassists', 'Meanboosts',
'MeandamageDealt', 'MeanDBNOs', 'MeanheadshotKills', 'Meanheals',
'MeankillPlace', 'MeankillPoints', 'Meankills', 'MeankillStreaks',
'MeanlongestKill', 'MeanmatchDuration', 'MeanmaxPlace', 'MeannumGroups',
'MeanrankPoints', 'Meanrevives', 'MeanrideDistance', 'MeanroadKills',
'MeanswimDistance', 'MeanteamKills', 'MeanvehicleDestroys',
'MeanwalkDistance', 'MeanweaponsAcquired', 'MeanwinPoints',
]:
a='Mean2'+i
print(a)
 testg[a] = testg.groupby(['matchId'])[i].transform('mean')
 traing[a] = traing.groupby(['matchId'])[i].transform('mean')
 testg[a] = testg[a].fillna(0)
 traing[a] = traing[a].fillna(0 )
n_classes = 10
print("Shape before one-hot encoding: ", y_train.shape)
 Y_train = np_utils.to_categorical(y_train, n_classes)
 Y_test = np_utils.to_categorical(y_test, n_classes)
 print("Shape after one-hot encoding: ", Y_train.shape )<choose_model_class>
temp1=testg['groupId']
model = Sequential()
model.add(Conv2D(filters=32, kernel_size=(5,5), padding='same', activation='relu', input_shape=(28, 28, 1)))
 model.add(MaxPool2D(pool_size = 2,strides=2))
model.add(Conv2D(filters=48, kernel_size=(5,5), padding='valid', activation='relu'))
model.add(MaxPool2D(pool_size = 2,strides=2))
model.add(Flatten())
 model.add(Dense(120, activation='relu'))
model.add(Dense(84, activation='relu'))
model.add(Dense(10, activation='softmax'))
adam = Adam(lr=5e-4)
 model.compile(loss='categorical_crossentropy', metrics=['accuracy'], optimizer=adam )<choose_model_class>
temp2=pd.DataFrame()
temp2['groupId']=testg['groupId']
temp2['NumberOfGroups']=testg['NumberOfGroups']
temp2['maxPlace']=testg['MeanmaxPlace']
reduce_lr = ReduceLROnPlateau(monitor='val_acc',
patience=3,
verbose=1,
factor=0.2,
min_lr=1e-6 )<train_model>
testg=testg.drop(columns=["Id"])
 testg=testg.drop(columns=["groupId"])
 testg=testg.drop(columns=["matchId"])
datagen = ImageDataGenerator(
 rotation_range=10,
width_shift_range=0.1,
height_shift_range=0.1,
zoom_range=0.1)
 history = datagen.fit(X_train )<train_model>
traing=traing.drop(columns=["Id"])
 traing=traing.drop(columns=["groupId"])
 traing=traing.drop(columns=["matchId"] )
history = model.fit_generator(datagen.flow(X_train, Y_train, batch_size=100), steps_per_epoch=len(X_train)/100,
epochs=20, validation_data=(X_test, Y_test), callbacks=[reduce_lr] )<train_model>
traing.isna().sum().sum()
<compute_test_metric>
sc = StandardScaler()
X_train = sc.fit_transform(traing)
score = model.evaluate(X_test, Y_test, verbose=0)
 print('Test loss:', score[0])
 print('Test accuracy:', score[1] )<load_from_csv>
X_test = sc.transform(testg)
test_data = pd.read_csv('/kaggle/input/digit-recognizer/test.csv' )<data_type_conversions>
del traing
del testg
test_data = test_data.values
test_data = test_data.reshape(28000, 28, 28,1)
 test_data = test_data.astype('float32')
 test_data /= 255
print("Test data matrix shape", test_data.shape )<predict_on_test>
from keras.models import Sequential
from keras.layers import Dense
from keras.layers import Dropout
from keras.wrappers.scikit_learn import KerasRegressor
from sklearn.cross_validation import cross_val_score, KFold
from sklearn.preprocessing import StandardScaler
from sklearn.pipeline import Pipeline
y_pred = model.predict_classes(test_data, verbose=0)
 print(y_pred )<predict_on_test>
model = Sequential()
model.add(Dense(163, input_dim=X_train.shape[1], kernel_initializer='normal', activation='linear'))
model.add(Dense(326, activation='relu'))
model.add(Dense(163, activation='relu'))
model.add(Dense(1, activation='sigmoid'))
model.summary()
i = 9713
predicted_value = np.argmax(model.predict(X_test[i].reshape(1,28, 28,1)))
 print('predicted value:',predicted_value)
 plt.imshow(X_test[i].reshape([28, 28]), cmap='Greys_r' )<save_to_csv>
model.compile(loss='mae', optimizer='adam', metrics=['mae'])
 model.fit(X_train,Y, epochs=1, batch_size=50 )
submissions=pd.DataFrame({"ImageId": list(range(1,len(y_pred)+1)) ,
"Label": y_pred})
 submissions.to_csv("LeNet_CNN.csv", index=False )<import_modules>
model.compile(loss='mae', optimizer='adam', metrics=['mae'])
 model.fit(X_train,Y, epochs=2, batch_size=100 )
random_seed = 2020
np.random.seed(random_seed)
<load_from_csv>
model.fit(X_train,Y, epochs=10, batch_size=1000 )
train = pd.read_csv('.. /input/digit-recognizer/train.csv')
 test = pd.read_csv('.. /input/digit-recognizer/test.csv')
 Y = train['label']
X = train.drop(labels="label", axis=1)
 X = X.values.reshape(-1, 28, 28, 1)/ 255
test = test.values.reshape(-1, 28, 28, 1)/ 255
print(X.shape, test.shape )<choose_model_class>
model.fit(X_train,Y, epochs=20, batch_size=10000 )
learning_rate_reduction = ReduceLROnPlateau(monitor = 'val_acc',
patience = 3,
verbose = 1,
factor = 0.5,
min_lr = 0.0001)
 es = EarlyStopping(monitor='val_loss',
mode='min',
verbose=1,
patience=15,
restore_best_weights=True)
 def new_model(hidden=512, learning_rate=0.00128):
INPUT = Input(( 28, 28, 1))
inputs = Conv2D(64,(5, 5), activation='relu', padding='same' )(INPUT)
 inputs = MaxPool2D(pool_size=(3,3), strides=(1,1))(inputs)
 inputs = BatchNormalization()(inputs)
 inputs = Activation('relu' )(inputs)
 inputs = Dropout(0.25 )(inputs)
 tower_1 = Conv2D(64,(1, 1), activation='relu', padding='same' )(inputs)
 tower_1 = Conv2D(128,(2, 2), activation='relu', padding='same' )(tower_1)
 tower_1 = Dropout(0.5 )(tower_1)
 tower_1 = Conv2D(256,(3, 3), activation='relu', padding='same' )(tower_1)
 tower_1 = MaxPool2D(pool_size=(3,3), strides=(2,2))(tower_1)
 tower_1 = BatchNormalization()(tower_1)
 tower_2 = Conv2D(64,(2, 2), activation='relu', padding='same' )(inputs)
 tower_2 = Conv2D(128,(3, 3), activation='relu', padding='same' )(tower_2)
 tower_2 = Dropout(0.5 )(tower_2)
 tower_2 = Conv2D(256,(5, 5), activation='relu', padding='same' )(tower_2)
 tower_2 = MaxPool2D(pool_size=(3,3), strides=(2,2))(tower_2)
 tower_2 = BatchNormalization()(tower_2)
 tower_3 = Conv2D(64,(1, 1), activation='relu', padding='same' )(inputs)
 tower_3 = Conv2D(128,(3, 3), activation='relu', padding='same' )(tower_3)
 tower_3 = Dropout(0.5 )(tower_3)
 tower_3 = Conv2D(256,(5, 5), activation='relu', padding='same' )(tower_3)
 tower_3 = MaxPool2D(pool_size=(3,3), strides=(2,2))(tower_3)
 tower_3 = BatchNormalization()(tower_3)
 x = Add()([tower_1, tower_2, tower_3])
 x = Activation('relu' )(x)
 x = Conv2D(256,(5, 5), activation='relu', padding='same' )(x)
 x = MaxPool2D(pool_size=(5,5), strides=(4,4))(x)
 x = BatchNormalization()(x)
 x = Activation('relu' )(x)
 x = Flatten()(x)
 x = Dense(hidden, activation='relu' )(x)
 x = Dropout(0.5 )(x)
 x = Dense(hidden//4, activation='relu' )(x)
 x = Dropout(0.5 )(x)
 preds = Dense(10, activation='softmax', name='preds' )(x)
 model = Model(inputs=INPUT, outputs=preds)
 optimizer = Adam(lr=learning_rate)
 model.compile(optimizer=optimizer, loss='sparse_categorical_crossentropy', metrics=['acc'])
 return model
model = new_model()<train_model>
model.fit(X_train,Y, epochs=20, batch_size=100000 )
datagen = ImageDataGenerator(featurewise_center=False,
samplewise_center=False,
featurewise_std_normalization=False,
samplewise_std_normalization=False,
zca_whitening=False,
rotation_range=10,
zoom_range=0.1,
shear_range=0.02,
width_shift_range=0.1,
height_shift_range=0.1,
horizontal_flip=False,
vertical_flip=False )<train_model>
model.fit(X_train,Y, epochs=5, batch_size=300000 )
epochs = 200
batch_size = 128
print("Learning Properties: Epoch:%i \t Batch Size:%i" %(epochs, batch_size))
predict_accumulator = np.zeros(model.predict(test ).shape)
 accumulated_history = []
for i in range(1, 6):
X_train, X_val, Y_train, Y_val = train_test_split(X, Y, test_size=0.20, shuffle=True, random_state=random_seed*i)
 model = new_model(512, 0.01)
 datagen.fit(X_train)
 history = model.fit_generator(datagen.flow(X_train, Y_train, batch_size=batch_size),
epochs=epochs, validation_data=(X_val, Y_val), verbose=1,
steps_per_epoch=X_train.shape[0]//batch_size,
callbacks=[learning_rate_reduction, es],
workers=4)
 loss, acc = model.evaluate(X, Y)
 if acc > 0.99:
predict_accumulator += model.predict(test)*acc
accumulated_history.append(history)
 print("Current Predictions on fold number %i" %i)
 print(*np.argmax(predict_accumulator, axis=1), sep='\t' )<save_to_csv>
y_pred = model.predict(X_test)
print("Completed Training.")
 results = np.argmax(predict_accumulator, axis=1)
 results = pd.Series(results, name="Label")
 print("Saving prediction to output...")
 submission = pd.concat([pd.Series(range(1, 1+test.shape[0]), name="ImageId"), results], axis=1)
 submission.to_csv('submission.csv', index=False )<train_model>
y_pred= np.reshape(y_pred, np.shape(test_preprocessed.DBNOs)[0])
end_time = time.time()
total_time = int(end_time - start_time)
 print("Total time spent: %i hours, %i minutes, %i seconds" \
%(( total_time//3600),(total_time%3600)//60,(total_time%60)) )<import_modules>
y_pred[y_pred > 1] = 1
for dirname, _, filenames in os.walk('/kaggle/input'):
for filename in filenames:
print(os.path.join(dirname, filename)) 
<load_from_csv>
New= pd.DataFrame()
New['groupId']=temp1
train = pd.read_csv('/kaggle/input/digit-recognizer/train.csv')
 test = pd.read_csv("/kaggle/input/digit-recognizer/test.csv" )<prepare_x_and_y>
New['pred']=y_pred
X=train.iloc[:,1:].values
Y=train.iloc[:,0].values<categorify>
test = pd.read_csv('.. /input/test.csv' )
X = X.reshape(X.shape[0], 28, 28,1)
 print(X.shape)
 Y = keras.utils.to_categorical(Y, 10)
 print(Y.shape )<split>
New1= pd.DataFrame()
New1['Id']=test['Id']
New1['groupId']=test['groupId']
New1.head()
X_train, X_valid, Y_train, Y_valid = train_test_split(X, Y, test_size = 0.15, random_state=42 )<choose_model_class>
results= New1.merge(New,on='groupId' )
train_datagen = ImageDataGenerator(rescale = 1./255.,
rotation_range = 10,
width_shift_range = 0.15,
height_shift_range = 0.15,
shear_range = 0.1,
zoom_range = 0.2,
horizontal_flip = False )<define_variables>
results= results.merge(temp2,on='groupId')
 results["N"]=1/results["NumberOfGroups"]
results["M"]=results["pred"]/results["N"]
results["M"]=round(results["M"],0)
 results["M1"]=np.floor(results["M"])
 results["M2"]=np.ceil(results["M"])
 results["N1"] = results["N"]*results["M"]
results["N2"] = results["N"]*results["M1"]
results["N3"] = results["N"]*results["M2"]
results["K"]=1/results["maxPlace"]
results["L"]=results["pred"]/results["K"]
results["L"]=round(results["L"],0)
 results["Max1"] = results["K"]*results["L"]
results["K"]=1/(results["maxPlace"]-1)
 results["L"]=results["pred"]/results["K"]
results["L"]=round(results["L"],0)
 results["Max2"] = results["K"]*results["L"]
results["K"]=1/(results["NumberOfGroups"]-1)
 results["L"]=results["pred"]/results["K"]
results["L"]=round(results["L"],0)
 results["Max3"] = results["K"]*results["L"]
valid_datagen = ImageDataGenerator(rescale=1./255 )<choose_model_class>
results.loc[results.maxPlace==0 , 'Max2'] = 0
model = tf.keras.models.Sequential([
tf.keras.layers.Conv2D(64,(3,3), padding='same', input_shape=(28, 28, 1)) ,
tf.keras.layers.LeakyReLU(alpha=0.1),
tf.keras.layers.Conv2D(64,(3,3), padding='same'),
tf.keras.layers.LeakyReLU(alpha=0.1),
tf.keras.layers.MaxPooling2D(2, 2),
tf.keras.layers.Dropout(0.2),
tf.keras.layers.Conv2D(64,(3,3), padding='same'),
tf.keras.layers.LeakyReLU(alpha=0.1),
tf.keras.layers.Conv2D(128,(3,3), padding='same'),
tf.keras.layers.LeakyReLU(alpha=0.1),
tf.keras.layers.MaxPooling2D(2,2),
tf.keras.layers.Dropout(0.2),
tf.keras.layers.Conv2D(128,(3,3), padding='same'),
tf.keras.layers.LeakyReLU(alpha=0.1),
tf.keras.layers.Conv2D(256,(3,3), padding='same'),
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')
 ] )<define_variables>
results=results.fillna(0 )
initial_learningrate=1e-3
batch_size = 128
epochs = 40
input_shape =(28, 28, 1 )<normalization>
results[results['maxPlace']==0]
def lr_decay(epoch):
return initial_learningrate * 0.9 ** epoch<choose_model_class>
my_submission = pd.DataFrame({'Id': results.Id, 'winPlacePerc': results.N1})
 my_submission.to_csv('submission.csv', index=False)
model.compile(loss="categorical_crossentropy",
optimizer=RMSprop(lr=initial_learningrate),
metrics=['accuracy'] )<train_model>
my_submission = pd.DataFrame({'Id': results.Id, 'winPlacePerc': results.N2})
 my_submission.to_csv('submission1.csv', index=False )
history = model.fit_generator(
 train_datagen.flow(X_train,Y_train, 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 )<predict_on_test>
my_submission = pd.DataFrame({'Id': results.Id, 'winPlacePerc': results.N3})
 my_submission.to_csv('submission2.csv', index=False )
predictions = model.predict_classes(x_test/255.)<create_dataframe>
my_submission = pd.DataFrame({'Id': results.Id, 'winPlacePerc': results.pred})
 my_submission.to_csv('submission3.csv', index=False )
final=pd.DataFrame({"ImageId": list(range(1,len(predictions)+1)) ,
"Label": predictions} )<save_to_csv>
my_submission = pd.DataFrame({'Id': results.Id, 'winPlacePerc': results.Max1})
 my_submission.to_csv('submission4.csv', index=False )
final.to_csv("cnn_submission.csv",index=False)
<set_options>
my_submission = pd.DataFrame({'Id': results.Id, 'winPlacePerc': results.Max2})
 my_submission.to_csv('submission5.csv', index=False )
<load_from_csv><EOS> 
my_submission = pd.DataFrame({'Id': results.Id, 'winPlacePerc': results.Max3})
 my_submission.to_csv('submission5.csv', index=False )