Kaggle competition: PLAsTiCC Astronomical Classification
test_X.to_csv('test_features.csv', index=False )<normalization>
pdf=pd.read_csv(".. /input/mergeneural512newparamsless/mergeNeuralNTPost99.csv")
 pdf.shape
scaled_test_X = pd.DataFrame(scaler.transform(test_X), columns=test_X.columns)
 scaled_test_X.values[1117]<compute_train_metric>
def alterProbabilities(odf, sqrt=False):
df=copy.deepcopy(odf)
 for cindex in df.columns:
df['adjSum']=0
if cindex != 'object_id':
df.loc[:,'not_' + str(cindex)]=1.0 - df.loc[:,cindex]
zeroFilter=(df.loc[:,'not_' + str(cindex)]==0)
 df.loc[zeroFilter,'adj_' + str(cindex)]=999999
df.loc[~zeroFilter,'adj_' + str(cindex)]=df.loc[~zeroFilter,cindex] / df.loc[~zeroFilter,'not_' + str(cindex)]
if sqrt:
df['adj_' + str(cindex)]=np.sqrt(df['adj_' + str(cindex)])
 for cindex in odf.columns:
if cindex !='object_id':
df.loc[:,'adjSum']+=df.loc[:,'adj_' + str(cindex)]
for cindex in odf.columns:
if cindex !='object_id':
odf.loc[:,cindex]=df.loc[:,'adj_' + str(cindex)] / df.loc[:,'adjSum']
return odf, df
s, os=alterProbabilities(pdf)
 s.head()
n_fold = 5
def mae_cv(model):
folds = KFold(n_splits=n_fold, shuffle=True, random_state=42 ).get_n_splits(scaled_train_X.values)
 mae = -cross_val_score(model, scaled_train_X.values, train_y, scoring="neg_mean_absolute_error",
verbose=0,
cv=folds)
 return mae 
<init_hyperparams>
def GenUnknown(data):
return(((((( data["mymedian"])+(((data["mymean"])/ 2.0)))/2.0)) +(((((1.0)-(((data["mymax"])*(((data["mymax"])*(data["mymax"])))))))/ 2.0)))/2.0)
 feats = ['class_6', 'class_15', 'class_16', 'class_42', 'class_52', 'class_53',
'class_62', 'class_64', 'class_65', 'class_67', 'class_88', 'class_90',
'class_92', 'class_95']
y = pd.DataFrame()
y['mymean'] = s[feats].mean(axis=1)
 y['mymedian'] = s[feats].median(axis=1)
 y['mymax'] = s[feats].max(axis=1)
 s['class_99'] = GenUnknown(y )
%%time
lgb_params = {'num_leaves': 51,
'min_data_in_leaf': 10,
'objective':'regression',
'max_depth': -1,
'learning_rate': 0.001,
"boosting": "gbdt",
"feature_fraction": 0.91,
"bagging_freq": 1,
"bagging_fraction": 0.91,
"bagging_seed": 42,
"metric": 'mae',
"lambda_l1": 0.1,
"verbosity": -1,
"nthread": -1,
"random_state": 42}
lgb_model = lgb.LGBMRegressor(objective='regression',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_model)
 print("LGBM score: {:.4f}({:.4f})
 ".format(score.mean() , score.std()))
lgb_model<compute_train_metric>
s.to_csv('moreDecisiveNeural.csv', index=False )