#aa.to_csv('xgb1.csv',index=False)

xgb_model=xgb.XGBClassifier()
print('Train XGBoost model')    
params = {'nthread':[4],
          "objective": ["multi:softprob"],
          "learning_rate": [0.3],
          "max_depth": [6,15,30],
          "min_child_weight":[1],
          "subsample": [0.9],
          "colsample_bytree": [0.97],
          'seed':[0,88],
		  'missing':[-999],
          'n_estimators':[20]       
          }
#watchlist=[(dtrain,'train'),(dvalid,'eval')]

       
bst=GridSearchCV(xgb_model,params,n_jobs=10,cv=StratifiedKFold(y,n_folds=5,shuffle=True),scoring='log_loss',verbose=1,refit=True)


bst.fit(train[features], y)

#trust your CV!
best_parameters, score, _ = max(bst.grid_scores_, key=lambda x: x[1])
print('Raw mlogloss score:', score)
for param_name in sorted(best_parameters.keys()):
    print("%s: %r" % (param_name, best_parameters[param_name]))
y_pred = bst.predict_prob(test[features])