Kaggle competition: PLAsTiCC Astronomical Classification
lgb_gamma_model = lgb.LGBMRegressor(objective='gamma',num_leaves=5,
learning_rate=0.01, n_estimators=720,
bagging_freq = 5, feature_fraction = 0.2319,
feature_fraction_seed=9, bagging_seed=9,
min_data_in_leaf =6, min_sum_hessian_in_leaf = 11, n_jobs = -1)
 score = mae_cv(lgb_gamma_model)
 print("LGBM - gamma score: {:.4f}({:.4f})
 ".format(score.mean() , score.std()))
lgb_gamma_model<choose_model_class>
%%time
xgb_params = {'eta': 0.03,
'max_depth': 9,
'subsample': 0.85,
'objective': 'reg:linear',
'eval_metric': 'mae',
'silent': True,
'nthread': 4}
xgb_model = xgb.XGBRegressor(colsample_bytree=0.4603, gamma=0.0468,
learning_rate=0.05, max_depth=3,
min_child_weight=1.7817, n_estimators=2200,
reg_alpha=0.4640, reg_lambda=0.8571,
subsample=0.5213, silent=1,
random_state =7, nthread = -1, eval_metric = 'mae',)
 score = mae_cv(xgb_model)
 print("XGB score: {:.4f}({:.4f})
 ".format(score.mean() , score.std()))
xgb_model 
<compute_train_metric>
dflgbm = pd.read_csv(".. /input/adjustlgbm1003/justSetZeroProbas.csv")
 dflgbm=dflgbm.sort_values('object_id' ).reset_index(drop=True)
 dfnn=pd.read_csv(".. /input/neuralmoredecisive/moreDecisiveNeural.csv")
 dfnn=dfnn.sort_values('object_id' ).reset_index(drop=True)
 print(dflgbm.shape)
 print(dfnn.shape )
%%time
rf_model = RandomForestRegressor(n_estimators=120, n_jobs=-1, min_samples_leaf=1,
max_features = "auto",max_depth=15,)
 score = mae_cv(rf_model)
 print("Random Forest score: {:.4f}({:.4f})
 ".format(score.mean() , score.std()))
rf_model<compute_train_metric>
dfBlend=.5*dflgbm +.5*dfnn
dfBlend.loc[:,'object_id']=dflgbm.loc[:,'object_id']
%%time
params = {'loss_function':'MAE',}
cat_model = CatBoostRegressor(iterations=1000, eval_metric='MAE', verbose=False, **params)
 score = mae_cv(cat_model)
 print("Cat Boost score: {:.4f}({:.4f})
 ".format(score.mean() , score.std()))
cat_model<compute_train_metric>
dfs=[dflgbm, dfnn]
wts=[.5,.5]
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)
%%time
KRR_model = KernelRidge(alpha=0.6, kernel='polynomial', degree=2, coef0=2.5)
 score = mae_cv(KRR_model)
 print("Kernel Ridge score: {:.4f}({:.4f})
 ".format(score.mean() , score.std()))
print(score)
 KRR_model<compute_train_metric>
dfBlend.to_csv('lgbm50DecisiveNeural50.csv', index=False )