Kaggle competition: PLAsTiCC Astronomical Classification
for seg_id in tqdm_notebook(range(segments)) :
seg = train_df.iloc[seg_id*rows:seg_id*rows+rows]
create_features(seg_id, seg, train_X)
 train_y.loc[seg_id, 'time_to_failure'] = seg['time_to_failure'].values[-1]<normalization>
scaler = StandardScaler()
scaler.fit(train_X)
 scaled_train_X = pd.DataFrame(scaler.transform(train_X), columns=train_X.columns )<load_from_csv>
dflgbm = pd.read_csv(".. /input/adjustlgbm1003/justSetZeroProbas.csv")
 dflgbm=dflgbm.sort_values('object_id' ).reset_index(drop=True)
 dfnn=pd.read_csv(".. /input/fork-of-mergeneuralntpost99/mergeNeuralNTPost99.csv")
 dfnn=dfnn.sort_values('object_id' ).reset_index(drop=True)
 print(dflgbm.shape)
 print(dfnn.shape )
submission = pd.read_csv('.. /input/sample_submission.csv', index_col='seg_id')
 test_X = pd.DataFrame(columns=train_X.columns, dtype=np.float64, index=submission.index )<load_from_csv>
dfBlend=.55*dflgbm +.45*dfnn
dfBlend.loc[:,'object_id']=dflgbm.loc[:,'object_id']
for seg_id in tqdm_notebook(test_X.index):
seg = pd.read_csv('.. /input/test/' + seg_id + '.csv')
 create_features(seg_id, seg, test_X )<create_dataframe>
dfs=[dflgbm, dfnn]
wts=[.55,.45]
npc=1000
def validateBlend(bdf, dfs, wts, npc=1000):
recs=bdf.shape[0]
cols=len(bdf.columns)
 failures=0
for i in range(npc):
record=random.randint(0,recs-1)
 feat=bdf.columns[random.randint(0, cols-1)]
shouldBe=0
isVal=bdf.loc[record, feat]
for j in range(len(wts)) :
shouldBe += dfs[j].loc[record, feat] * wts[j]
shouldBe=round(shouldBe,6)
 isVal=round(isVal,6)
 if shouldBe==isVal:
dosomething=False
else:
print(record)
 print(feat)
 print('should be: ' + str(shouldBe))
print('is: ' + str(isVal))
failures+=1
print('total failures: ' + str(failures)+ ' out of ' + str(npc)+' sample points')
 return failures
failures=validateBlend(dfBlend, dfs, wts)
scaled_test_X = pd.DataFrame(scaler.transform(test_X), columns=test_X.columns )<normalization>
dfBlend.to_csv('lgbm55usnn45.csv', index=False )