Kaggle competition: NFL Big Data Bowl
<SOS> metric: CRPS Kaggle data source: nfl-big-data-bowl<define_variables>
warnings.filterwarnings('ignore')
 __print__ = print
def print(string):
os.system(f'echo "{string}"')
 __print__(string )
class Seq(object):
sections = None
index = None
SPLIT_LIST = [
np.array(range(256)) ,
np.array(range(256)) + 256
]
def __init__(self, df, extend=False, aug=False, test=False, batch_size=32):
self.shaffle = None
self.extend = extend
self.aug = aug
self.test = test
self.batch_size = batch_size
self.df = df
self.ids = self.df.Id.tolist()
self.reversed = sorted(range(SH_ALL[0]), reverse=True)
 self.initialize_it()
self.len = 1
for _ in self.it:
self.len += 1
self.initialize_it()
def initialize_it(self):
if self.shaffle:

 raise NotImplementedError
self.it = iter(range(0, len(self.ids), self.batch_size))
self.idx_next = self.it.__next__()
def __len__(self):
return self.len
def __iter__(self):
return self
def __next__(self):
idx = self.idx_next
self.ids_part = self.ids[idx:(( idx+self.batch_size)if idx+self.batch_size<len(self.ids)else len(self.ids)) ]
res = self.getpart(self.ids_part)
 try:
self.idx_next = self.it.__next__()
except StopIteration:
self.initialize_it()
return res
def __getitem__(self, id0):
arr, tgts = self.get_data(id0)
 cat = self.convert_tgts(tgts)
 return arr, cat
k_list = list(range(4))
def random_transform(self, arr):
k = random.choice(self.k_list)
 arr0 = np.rot90(arr, k=k)
 if random.randint(0,1):
arr0 = arr0[self.reversed,:,:]
if random.randint(0,1):
arr0 = arr0[:,self.reversed,:]
return arr0
def convert_tgts(self, tgts):
try:
cats = to_categorical(tgts, num_classes=28)
 cat = cats.sum(axis=0)
 except TypeError:
cat = np.zeros(( 28,))
return cat
def get_data(self, id0):
arr = get_arr0(id0, test=self.test)
 try:
y0 =(self.df.Target[self.df.Id == id0] ).tolist() [0]
y1 = y0.split()
y = [int(ee)for ee in y1]
except AttributeError:
y = None
return arr, y
def getpart(self, ids):
xs = []
ys = []
for id0 in ids:
self.extend_data(id0, xs, ys)
 x = np.stack(xs)
 y = np.stack(ys)
 x_dummy = np.zeros(( len(x), 1))
x_ret = {
'input': x,
'input_cls': y,
}
y_ret = {
'path_fit_cls_img': x_dummy,
'path_cls_img_cls': y,
'path_fit_imgA': x_dummy,
'path_fit_img_cls_img': x_dummy,
'path_cls_cls': y,
'path_img_cls': y,
'path_img_img_cls': y,
'path_fit_cls_img_imgE': x_dummy,
}
return(x_ret, y_ret)
 def split(self, arr):
res = []
for row_idx in self.SPLIT_LIST:
for col_idx in self.SPLIT_LIST:
res.append(arr[:, col_idx][row_idx].flatten())
 return res
def extend_data(self, id0, xs, ys):
arr0, cat = self[id0]
if self.extend:
mm = up_sample2[cat==1].max()
mm = int(mm)
 for ii in range(mm):
if self.aug:
img = self.random_transform(arr0)
 else:
img = arr0
xs.append(img.flatten())
 ys.append(cat)
 else:
if self.aug:
img0 = self.random_transform(arr0)
 else:
img0 = arr0
res = self.split(img0)
 res = np.concatenate(res)
 xs.append(res)
 ys.append(cat )<prepare_x_and_y>
df = pd.read_csv('/kaggle/input/nfl-big-data-bowl-2020/train.csv', low_memory=False)
 shape = str(df.shape)
 print(df.columns)
 print(df.shape )
arr, y = seq.get_data('ad5a4858-bb9d-11e8-b2b9-ac1f6b6435d0')
 print(arr.shape)
 show_arr(arr )<import_modules>
def prepare_data(df):
df.loc[df['StadiumType'].isnull() , 'StadiumType'] = 'Unknown'
df.loc[df['GameWeather'].isnull() , 'GameWeather'] = 'Unknown'
df.loc[df['WindDirection'].isnull() , 'WindDirection'] = 'Unknown'
df.loc[df['WindSpeed'].isnull() , 'WindSpeed'] = '0'
df.loc[df['Orientation'].isnull() , 'Orientation'] = 0
df.loc[df['Dir'].isnull() , 'Dir'] = 0
df.loc[df['GameWeather']== 'T: 51; H: 55; W: NW 10 mph', 'Temperature'] = 51
df.loc[df['GameWeather']== 'T: 51; H: 55; W: NW 10 mph', 'WindDirection'] = 'NW 10 mph'
df.loc[df['GameWeather']== 'T: 51; H: 55; W: NW 10 mph', 'Humidity'] = 55
df.loc[df['Temperature'].isnull() , 'Temperature'] = 70
df.loc[df['Humidity'].isnull() , 'Humidity'] = 0
df.loc[df['OffenseFormation'].isnull() , 'OffenseFormation'] = 'Unknown'
df.loc[df['PossessionTeam'] == df['HomeTeamAbbr'] , 'DefendingTeam'] = df['VisitorTeamAbbr']
df.loc[df['PossessionTeam'] != df['HomeTeamAbbr'] , 'DefendingTeam'] = df['HomeTeamAbbr']
df.loc[(df['FieldPosition'].isnull())&(df['PlayDirection'] == 'right')&(df['X'] >= 50), 'FieldPosition'] = df['DefendingTeam']
df.loc[(df['FieldPosition'].isnull())&(df['PlayDirection'] == 'right')&(df['X'] < 50), 'FieldPosition'] = df['PossessionTeam']
df.loc[(df['FieldPosition'].isnull())&(df['PlayDirection'] == 'left')&(df['X'] >= 50), 'FieldPosition'] = df['PossessionTeam']
df.loc[(df['FieldPosition'].isnull())&(df['PlayDirection'] == 'left')&(df['X'] < 50), 'FieldPosition'] = df['DefendingTeam']
df = df.dropna()
df['WindSpeed'] = df['WindSpeed'].astype('str')
 df['WindSpeed'] = df['WindSpeed'].str.replace('mph', '')
 df['WindSpeed'] = df['WindSpeed'].str.replace('Mph', '')
 df['WindSpeed'] = df['WindSpeed'].str.replace('MPH', '')
 df['WindSpeed'] = df['WindSpeed'].str.replace('MPh', '')
 df['WindSpeed'] = df['WindSpeed'].str.strip()
b = df['WindSpeed'].loc[df['WindSpeed'].str.contains('-', regex=False)==True].unique()
b1 = df['WindSpeed'].loc[df['WindSpeed'].str.contains('-', regex=False)==True].str[:2]
b2 = df['WindSpeed'].loc[df['WindSpeed'].str.contains('-', regex=False)==True].str[-2:]
b3 =(b1.astype('float64')+ b2.astype('float64')) / 2
for i in b:
df.loc[(df.WindSpeed == i), 'WindSpeed'] = b3
v = df[df['WindSpeed'].str.isnumeric() == False]
av = v['WindSpeed'].unique()
for j in av:
df.loc[(df.WindSpeed == j), 'WindSpeed'] = '0.0'
df['WindSpeed'] = df['WindSpeed'].astype('float64')
 df.X[df['PlayDirection'] == 'left'] = 120 - df['X']
df.YardLine[df['PossessionTeam'] == df['FieldPosition']] = 10 + df['YardLine']
df.YardLine[df['PossessionTeam'] != df['FieldPosition']] = 60.0 +(50 - df['YardLine'])
 df.Orientation[df['PlayDirection'] == 'left'] = 360 - df['Orientation']
df.loc[(df['PlayDirection'] == 'left')&(df['Orientation'] == 0),'Orientation'] = 0
df.Orientation[df['PlayDirection'] == 'left'] = 360 - df['Dir']
df.loc[(df['PlayDirection'] == 'left')&(df['Dir'] == 0),'Dir'] = 0
nfl = {
1:	'ARI',
2:	'ATL',
3:	'BAL',
4:	'BUF',
5:	'CAR',
6:	'CHI',
7:	'CIN',
8:	'CLE',
9:	'DAL',
10:	'DEN',
11:	'DET',
12:	'GB',
13:	'HOU',
14:	'IND',
15:	'JAX',
16:	'KC',
17:	'LAC',
18:	'LAR',
19:	'MIA',
20:	'MIN',
21:	'NE',
22:	'NO',
23:	'NYG',
24:	'NYJ',
25:	'OAK',
26:	'PHI',
27:	'PIT',
28:	'SEA',
29:	'SF',
30:	'TB',
31:	'TEN',
32:	'WAS'
}
nfl_teams = pd.DataFrame.from_dict(nfl, orient='index')
 nfl_teams['team_id'] = nfl_teams.index
nfl_teams = nfl_teams.rename(columns={0: 'team_abb'})
 	
df.loc[df['HomeTeamAbbr'] == 'ARZ', 'HomeTeamAbbr'] = 'ARI'
df.loc[df['HomeTeamAbbr'] == 'BLT', 'HomeTeamAbbr'] = 'BAL'
df.loc[df['HomeTeamAbbr'] == 'CLV', 'HomeTeamAbbr'] = 'CLE'
df.loc[df['HomeTeamAbbr'] == 'HST', 'HomeTeamAbbr'] = 'HOU'
df.loc[df['HomeTeamAbbr'] == 'LA', 'HomeTeamAbbr'] = 'LAR'
df.loc[df['VisitorTeamAbbr'] == 'ARZ', 'VisitorTeamAbbr'] = 'ARI'
df.loc[df['VisitorTeamAbbr'] == 'BLT', 'VisitorTeamAbbr'] = 'BAL'
df.loc[df['VisitorTeamAbbr'] == 'CLV', 'VisitorTeamAbbr'] = 'CLE'
df.loc[df['VisitorTeamAbbr'] == 'HST', 'VisitorTeamAbbr'] = 'HOU'
df.loc[df['VisitorTeamAbbr'] == 'LA', 'VisitorTeamAbbr'] = 'LAR'
df = df.merge(nfl_teams, left_on ='HomeTeamAbbr', right_on ='team_abb', how = 'left')
 df = df.drop(['HomeTeamAbbr','team_abb'], axis=1)
 df = df.rename(columns={'team_id': 'HomeTeamAbbr'})
 	
df = df.merge(nfl_teams, left_on ='VisitorTeamAbbr', right_on ='team_abb', how = 'left')
 df = df.drop(['VisitorTeamAbbr','team_abb'], axis=1)
 df = df.rename(columns={'team_id': 'VisitorTeamAbbr'})
 	
df['HomeTeamAbbr'] = df['HomeTeamAbbr'].astype('float64')
 df['VisitorTeamAbbr'] = df['VisitorTeamAbbr'].astype('float64')
 	
df.loc[df['FieldPosition'] == 'ARZ', 'FieldPosition'] = 'ARI'
df.loc[df['FieldPosition'] == 'BLT', 'FieldPosition'] = 'BAL'
df.loc[df['FieldPosition'] == 'CLV', 'FieldPosition'] = 'CLE'
df.loc[df['FieldPosition'] == 'HST', 'FieldPosition'] = 'HOU'
df.loc[df['FieldPosition'] == 'LA', 'FieldPosition'] = 'LAR'
df.loc[df['PossessionTeam'] == 'ARZ', 'PossessionTeam'] = 'ARI'
df.loc[df['PossessionTeam'] == 'BLT', 'PossessionTeam'] = 'BAL'
df.loc[df['PossessionTeam'] == 'CLV', 'PossessionTeam'] = 'CLE'
df.loc[df['PossessionTeam'] == 'HST', 'PossessionTeam'] = 'HOU'
df.loc[df['PossessionTeam'] == 'LA', 'PossessionTeam'] = 'LAR'
df = df.merge(nfl_teams, left_on ='FieldPosition', right_on ='team_abb', how = 'left')
 df = df.drop(['FieldPosition','team_abb'], axis=1)
 df = df.rename(columns={'team_id': 'FieldPosition'})
 df = df.merge(nfl_teams, left_on ='PossessionTeam', right_on ='team_abb', how = 'left')
 df = df.drop(['PossessionTeam','team_abb'], axis=1)
 df = df.rename(columns={'team_id': 'PossessionTeam'})
 df['FieldPosition'] = df['FieldPosition'].astype('float64')
 df['PossessionTeam'] = df['PossessionTeam'].astype('float64')
 	
df['DefensePersonnel_DL'] = df['DefensePersonnel'].str.replace(', ', '_' ).str.replace(' ', '' ).str.slice(0, 1)
 df['DefensePersonnel_LB'] = df['DefensePersonnel'].str.replace(', ', '_' ).str.replace(' ', '' ).str.slice(4, 5)
 df['DefensePersonnel_DB'] = df['DefensePersonnel'].str.replace(', ', '_' ).str.replace(' ', '' ).str.slice(8, 9)
 df['DefensePersonnel_DL'] = df['DefensePersonnel_DL'].astype('int64')
 df['DefensePersonnel_LB'] = df['DefensePersonnel_LB'].astype('int64')
 df['DefensePersonnel_DB'] = df['DefensePersonnel_DB'].astype('int64')
 	
df.loc[df['OffensePersonnel'].str.replace(', ', '_' ).str.replace(' ', '' ).str.slice(1, 3)== 'OL', 'OffensePersonnel_Flag'] = 1
df.loc[df['OffensePersonnel'].str.replace(', ', '_' ).str.replace(' ', '' ).str.slice(1, 3)== 'QB', 'OffensePersonnel_Flag'] = 2
df.loc[df['OffensePersonnel'].str.replace(', ', '_' ).str.replace(' ', '' ).str.slice(1, 3)== 'RB', 'OffensePersonnel_Flag'] = 0
	
df.loc[df['OffensePersonnel_Flag'] == 2, 'OffensePersonnel_QB'] = df['OffensePersonnel'].str.replace(', ', '_' ).str.replace(' ', '' ).str.slice(0, 1)
 df.loc[df['OffensePersonnel_Flag'] == 2, 'OffensePersonnel_RB'] = df['OffensePersonnel'].str.replace(', ', '_' ).str.replace(' ', '' ).str.slice(4, 5)
 df.loc[df['OffensePersonnel_Flag'] == 2, 'OffensePersonnel_TE'] = df['OffensePersonnel'].str.replace(', ', '_' ).str.replace(' ', '' ).str.slice(8, 9)
 df.loc[df['OffensePersonnel_Flag'] == 2, 'OffensePersonnel_WR'] = df['OffensePersonnel'].str.replace(', ', '_' ).str.replace(' ', '' ).str.slice(12, 13)
 df.loc[df['OffensePersonnel_Flag'] != 2, 'OffensePersonnel_QB'] = '1'
	
df.loc[df['OffensePersonnel_Flag'] == 1, 'OffensePersonnel_OL'] = df['OffensePersonnel'].str.replace(', ', '_' ).str.replace(' ', '' ).str.slice(0, 1)
 df.loc[df['OffensePersonnel_Flag'] == 1, 'OffensePersonnel_RB'] = df['OffensePersonnel'].str.replace(', ', '_' ).str.replace(' ', '' ).str.slice(4, 5)
 df.loc[df['OffensePersonnel_Flag'] == 1, 'OffensePersonnel_TE'] = df['OffensePersonnel'].str.replace(', ', '_' ).str.replace(' ', '' ).str.slice(8, 9)
 df.loc[df['OffensePersonnel_Flag'] == 1, 'OffensePersonnel_WR'] = df['OffensePersonnel'].str.replace(', ', '_' ).str.replace(' ', '' ).str.slice(12, 13)
 	
df.loc[df['OffensePersonnel_Flag'] == 0, 'OffensePersonnel_RB'] = df['OffensePersonnel'].str.replace(', ', '_' ).str.replace(' ', '' ).str.slice(0, 1)
 df.loc[df['OffensePersonnel_Flag'] == 0, 'OffensePersonnel_TE'] = df['OffensePersonnel'].str.replace(', ', '_' ).str.replace(' ', '' ).str.slice(4, 5)
 df.loc[df['OffensePersonnel_Flag'] == 0, 'OffensePersonnel_WR'] = df['OffensePersonnel'].str.replace(', ', '_' ).str.replace(' ', '' ).str.slice(8, 9)
 	
df['OffensePersonnel_QB'] = df['OffensePersonnel_QB'].astype('int64')
 df['OffensePersonnel_RB'] = df['OffensePersonnel_RB'].astype('int64')
 df['OffensePersonnel_TE'] = df['OffensePersonnel_TE'].astype('int64')
 df['OffensePersonnel_WR'] = df['OffensePersonnel_WR'].astype('int64')
 df.loc[df['OffensePersonnel_Flag'] != 1, 'OffensePersonnel_OL_tmp'] = 11 -(df['OffensePersonnel_RB'] + df['OffensePersonnel_TE'] + df['OffensePersonnel_WR']+df['OffensePersonnel_QB'])
 df.loc[df['OffensePersonnel_Flag'] != 1, 'OffensePersonnel_OL'] = df['OffensePersonnel_OL_tmp']
df['OffensePersonnel_OL'] = df['OffensePersonnel_OL'].astype('int64')
 df = df.drop(['OffensePersonnel_OL_tmp'], axis=1)
 	
	
	
PlayerHeight_ft=df['PlayerHeight'].str.split('-' ).str[0].astype('float64')
 PlayerHeight_in=df['PlayerHeight'].str.split('-' ).str[1].astype('float64')
 PlayerHeight_m = PlayerHeight_ft*0.3048 + PlayerHeight_in*0.0254
df['PlayerHeight'] = PlayerHeight_m.astype('float64')
 	
time_snap_handoff = pd.to_datetime(df['TimeHandoff'])- pd.to_datetime(df['TimeSnap'])
 time_snap_handoff_sec = pd.to_timedelta(time_snap_handoff)
 df['TimeSnapHandoff'] = time_snap_handoff_sec.dt.seconds.astype('int64')
 df['GameYear'] = pd.DatetimeIndex(df['TimeSnap'] ).year
df['GameMonth'] = pd.DatetimeIndex(df['TimeSnap'] ).month
df['GameDay'] = pd.DatetimeIndex(df['TimeSnap'] ).day
today=dt.datetime.today().strftime('%Y-%m-%d')
 today=pd.to_datetime(today)
 PlayerAgeDays = today - pd.to_datetime(df['PlayerBirthDate'])
 df['PlayerAgeYears'] = PlayerAgeDays/np.timedelta64(1,'Y')
 GameClockMin = pd.DatetimeIndex(df['GameClock'] ).hour
GameClockSec = pd.DatetimeIndex(df['GameClock'] ).minute
df['GameClockSeconds'] = GameClockMin*60 + GameClockSec
columns_to_drop = ['GameClock','TimeSnap','TimeHandoff','PlayerBirthDate', 'JerseyNumber',
'OffensePersonnel', 'DefensePersonnel','PlayerCollegeName']
df = df.drop(columns_to_drop, axis=1)
 df.columns
return df
from keras import applications<categorify>
def transform_data(df):
categorical_feature_mask = df.dtypes==object
categorical_cols = df.columns[categorical_feature_mask].tolist()
print(categorical_cols)
 le = LabelEncoder()
df[categorical_cols] = df[categorical_cols].apply(lambda col: le.fit_transform(col))
return df
def make_trainable_false(model_resnet, trainable=False):
layers = model_resnet.layers
for ilayer in layers:
ilayer.trainable = trainable
return<choose_model_class>
dfa = prepare_data(df )
def make_model_cnvt(img_dim, img_shape):

 inp = Input(shape=(img_dim,))
oup = Reshape(img_shape )(inp)
 oup = Conv2D(3,
kernel_size=1,
strides=1,
padding='same',
activation='tanh',
kernel_regularizer=regularizers.l2(0))(oup)
 model_cnvt = Model(inp, oup, name='model_cnvt')
 return model_cnvt<choose_model_class>
dfa_sc = transform_data(dfa )
def make_model_classifier(input_dim=1536):
inp_cls = Input(( input_dim,))
oup_cls = Dense(28 )(inp_cls)
 oup_cls = Activation('sigmoid' )(oup_cls)
 model_classifier = Model(inp_cls, oup_cls, name='classifier')
 return model_classifier<choose_model_class>
feature_names = ['Team', 'X', 'Y', 'S', 'A', 'Dis', 'Orientation', 'Dir', 'NflId',
'Season', 'YardLine', 'Quarter', 'PossessionTeam', 'Down', 'Distance',
'FieldPosition', 'HomeScoreBeforePlay', 'VisitorScoreBeforePlay',
'NflIdRusher', 'OffenseFormation', 'DefendersInTheBox', 'PlayDirection',
'PlayerHeight', 'PlayerWeight', 'Position', 'HomeTeamAbbr',
'VisitorTeamAbbr', 'Week', 'Stadium', 'Location', 'StadiumType', 'Turf',
'GameWeather', 'Temperature', 'Humidity', 'WindSpeed', 'WindDirection',
'DefensePersonnel_DL', 'DefensePersonnel_LB', 'DefensePersonnel_DB',
'OffensePersonnel_Flag', 'OffensePersonnel_QB', 'OffensePersonnel_RB',
'OffensePersonnel_TE', 'OffensePersonnel_WR', 'OffensePersonnel_OL',
'TimeSnapHandoff', 'GameYear', 'GameMonth', 'GameDay', 'PlayerAgeYears',
'GameClockSeconds']
dfy = dfa_sc[['Yards']]
dfX = dfa_sc[feature_names]
yards = dfy.Yards
y = np.zeros(( yards.shape[0], 199))
for idx, target in enumerate(list(yards)) :
y[idx][99 + target] = 1
def make_model(img_dim, model_cnvt, model_resnet, model_classifier):
inp0 = Input(shape=(int(img_dim/4),), name='input0')
 oup0 = model_cnvt(inp0)
 oup0 = model_resnet(oup0)
 oup0 = model_classifier(oup0)
 oup0 = Activation('linear', name='path_cls_cls' )(oup0)
 model0 = Model(inp0, oup0, name='model0')

def fn(x, idx):
x1 = K.permute_dimensions(x,(1,0,2,))
x2 = K.gather(x1, idx)
 return x2
inp = Input(shape=(img_dim,), name='input')
 oup = Reshape(( 4,int(img_dim/4)) )(inp)
 img0 = Lambda(lambda x: fn(x, 0))(oup)
 img1 = Lambda(lambda x: fn(x, 1))(oup)
 img2 = Lambda(lambda x: fn(x, 2))(oup)
 img3 = Lambda(lambda x: fn(x, 3))(oup)
 oup = Lambda(lambda x: K.stack(x, 1))([model0(img0), model0(img1), model0(img2), model0(img3)])
 oup = GlobalMaxPooling1D()(oup)
 oup = Activation('linear', name='path_cls_cls' )(oup)
 model = Model(inp, oup, name='model')
 return {
'model_classifier': model_classifier,
'model_resnet': model_resnet,
'model_cnvt': model_cnvt,
'model': model,
'model0': model0
}<categorify>
def crps(y_true, y_pred):
y_true = np.clip(np.cumsum(y_true, axis=1), 0, 1)
 y_pred = np.clip(np.cumsum(y_pred, axis=1), 0, 1)
 return(( y_true - y_pred)** 2 ).sum(axis=1 ).sum(axis=0)/(199 * y_true.shape[0] )
model_cnvt.layers[2].get_weights()<load_pretrained>
models = []
kf = KFold(n_splits=4, random_state=42)
 score = []
for i,(train_index, test_index)in enumerate(kf.split(dfX, y)) :
print(f'Fold : {i}')
 X_train, X_test = dfX.iloc[train_index], dfX.iloc[test_index]
y_train, y_test = y[train_index], y[test_index]
model = RandomForestRegressor(n_estimators=20, random_state=0)
 model.fit(X_train, y_train)
 score_rf_crps = crps(y_test, model.predict(X_test))
print(score_rf_crps)
 score.append(score_rf_crps)
 models.append(model)
 print(np.mean(score_rf_crps))
<choose_model_class><EOS> 
env = nflrush.make_env()
for(test_df, sample_prediction_df)in env.iter_test() :
dfb = prepare_data(test_df)
 feature_names = ['Team', 'X', 'Y', 'S', 'A', 'Dis', 'Orientation', 'Dir', 'NflId',
'Season', 'YardLine', 'Quarter', 'PossessionTeam', 'Down', 'Distance',
'FieldPosition', 'HomeScoreBeforePlay', 'VisitorScoreBeforePlay',
'NflIdRusher', 'OffenseFormation', 'DefendersInTheBox', 'PlayDirection',
'PlayerHeight', 'PlayerWeight', 'Position', 'HomeTeamAbbr',
'VisitorTeamAbbr', 'Week', 'Stadium', 'Location', 'StadiumType', 'Turf',
'GameWeather', 'Temperature', 'Humidity', 'WindSpeed', 'WindDirection',
'DefensePersonnel_DL', 'DefensePersonnel_LB', 'DefensePersonnel_DB',
'OffensePersonnel_Flag', 'OffensePersonnel_QB', 'OffensePersonnel_RB',
'OffensePersonnel_TE', 'OffensePersonnel_WR', 'OffensePersonnel_OL',
'TimeSnapHandoff', 'GameYear', 'GameMonth', 'GameDay', 'PlayerAgeYears',
'GameClockSeconds']
dfb_sc = transform_data(dfb)
 dfb_sc_final = dfb[feature_names]
y_pred = np.mean([model.predict(dfb_sc_final)for model in models],axis=0)
 y_pred = np.clip(np.cumsum(y_pred, axis=1), 0, 1 ).tolist() [0]
preds_df = pd.DataFrame(data=[y_pred], columns=sample_prediction_df.columns)
 env.predict(preds_df)
 env.write_submission_file()