Kaggle competition: Microsoft Malware Prediction
params = {
"max_depth": [2, 3, 6, 10],
"max_features": ["auto",0.3, 0.6],
"min_samples_leaf": [1,3],
"min_samples_split": [2, 5],
"n_estimators": [30, 50, 100, 200],
"random_state" : [42],
"tol" : [0.0001, 0.001, 0.01, 0.1]
}
GBR = GradientBoostingRegressor()
GBR_grid = GridSearchCV(GBR, params, scoring='r2', cv=7, n_jobs=-1)
 GBR_grid.fit(X_train, y_train)
 print("Best parameters: {}:".format(GBR_grid.best_params_))
print("Best score: {}".format(GBR_grid.best_score_))
best_estimators.append(["GradientBoostR",GBR_grid.best_estimator_] )<feature_engineering>
dtypes = {}
dtypes['MachineIdentifier'] = 'str'
dtypes['AvSigVersion'] = 'category'
dtypes['HasDetections'] = 'int8'
df_train = pd.read_csv('.. /input/microsoft-malware-prediction/train.csv', usecols=list(dtypes.keys()), dtype=dtypes)
 print('Loaded',len(df_train),'rows of train.CSV!')
 df_test = pd.read_csv('.. /input/microsoft-malware-prediction/test.csv', usecols=list(dtypes.keys())[0:-1], dtype=dtypes)
 print('Loaded',len(df_test),'rows of test.CSV!')
 df_test2 = pd.read_csv('.. /input/malware-detection-stacking-2-0/submission_kfold.csv')
 print('Loaded',len(df_test),'rows of submission_kfold.csv!')
 datedictAS = np.load('.. /input/malware-timestamps/AvSigVersionTimestamps.npy')[() ]
df_test['Date'] = df_test['AvSigVersion'].map(datedictAS)
 df_train['Date'] = df_train['AvSigVersion'].map(datedictAS)
 df_test2 = pd.merge(df_test2, df_test, on='MachineIdentifier', how='left')
 df_test2['AvSigVersion2'] = df_test2['AvSigVersion'].map(lambda x: np.int(x.split('.')[1]))
evaluate = pd.DataFrame(columns=["model","cv","std"])
 for name,model in pipelines:
kfold = KFold(n_splits=10,random_state=42)
 cv = cross_val_score(model, X_train, y_train, cv=kfold, n_jobs=-1, scoring="neg_root_mean_squared_error")
 row = evaluate.shape[0]
evaluate.loc[row,"model"] = name
evaluate.loc[row,"cv"] = round(cv.mean() ,3)
 evaluate.loc[row,"std"] = "+/- {}".format(round(cv.std() ,4))
evaluate = evaluate.sort_values("cv",ascending=False)
 evaluate<define_search_model>
df_test2.loc[(df_test2['AvSigVersion2']==275)|(df_test2['AvSigVersion2']==273),'HasDetections'] *= 0.8
votings = []
votings.append(["Scaled_RFR",RFR_grid.best_estimator_])
 votings.append(( "Scaled_all_models",Pipeline([("Scaler",StandardScaler()), 
("Votings",VotingRegressor([("RFR",RFR_grid.best_estimator_), 
("AdaBoostR", AdaBoostR_grid.best_estimator_), 
("BaggingR",BR_grid.best_estimator_), 
("GBR",GBR_grid.best_estimator_)
 ])
)])))
 votings.append(( "Scaled_RFR_BR_GBR",Pipeline([("Scaler",StandardScaler()), 
("Votings",VotingRegressor([("RFR",RFR_grid.best_estimator_), 
("BaggingR",BR_grid.best_estimator_), 
("GBR",GBR_grid.best_estimator_)
 ])
)])))
 votings.append(( "Scaled_RFR_BR_AdaBR",Pipeline([("Scaler",StandardScaler()), 
("Votings",VotingRegressor([("RFR",RFR_grid.best_estimator_), 
("BaggingR",BR_grid.best_estimator_), 
("AdaBoostR", AdaBoostR_grid.best_estimator_)
 ])
)])))
 votings.append(( "Scaled_AdaBR_GBR",Pipeline([("Scaler",StandardScaler()), 
("Votings",VotingRegressor([("RFR",RFR_grid.best_estimator_), 
("AdaBoostR", AdaBoostR_grid.best_estimator_), 
("GBR",GBR_grid.best_estimator_)
 ])
)])))
 votings.append(( "Scaled_BR_GBR_AdaBR",Pipeline([("Scaler",StandardScaler()), 
("Votings",VotingRegressor([("BaggingR",BR_grid.best_estimator_), 
("GBR",GBR_grid.best_estimator_), 
("AdaBoostR", AdaBoostR_grid.best_estimator_)
 ])
)])))
 votings.append(( "Scaled_BR_GBR",Pipeline([("Scaler",StandardScaler()), 
("Votings",VotingRegressor([("BaggingR",BR_grid.best_estimator_), 
("GBR",GBR_grid.best_estimator_)
 ])
)])))
 votings.append(( "Scaled_BR_AdaBR",Pipeline([("Scaler",StandardScaler()), 
("Votings",VotingRegressor([("BaggingR",BR_grid.best_estimator_), 
("AdaBoostR", AdaBoostR_grid.best_estimator_)
 ])
)])))
 votings.append(( "Scaled_BR_RFR",Pipeline([("Scaler",StandardScaler()), 
("Votings",VotingRegressor([("BaggingR",BR_grid.best_estimator_), 
("RFR",RFR_grid.best_estimator_)
 ])
)])))
 votings.append(( "Scaled_GBR_AdaBR",Pipeline([("Scaler",StandardScaler()), 
("Votings",VotingRegressor([("GBR",GBR_grid.best_estimator_), 
("AdaBoostR", AdaBoostR_grid.best_estimator_)
 ])
)])))
 votings.append(( "Scaled_GBR_RFR",Pipeline([("Scaler",StandardScaler()), 
("Votings",VotingRegressor([("GBR",GBR_grid.best_estimator_), 
("RFR",RFR_grid.best_estimator_)
 ])
)])))
 votings.append(( "Scaled_AdaBR_RFR",Pipeline([("Scaler",StandardScaler()), 
("Votings",VotingRegressor([("AdaBoostR", AdaBoostR_grid.best_estimator_), 
("RFR",RFR_grid.best_estimator_)
 ])
)])) )<feature_engineering>
df_test2.loc[ df_test2['Date']>datetime(2018,11,21,0,0),'HasDetections'] *= 0.4
df_test2.loc[ df_test2['Date']>datetime(2018,11,24,0,0),'HasDetections'] *= 0.4
<save_to_csv><EOS> 
df_test2[['MachineIdentifier','HasDetections']].to_csv('PrivateLeaderboard.csv', index=False )