def ensemble_submission(self): """ For all the models specified in self.d_model, train them and apply them on the test data to create a submission file """ # Loop over possible ensemblers for model_name in self.d_model.keys() : # Only train if desired if self.d_model[model_name]["train"]: # Get data feat_choice = self.d_model[model_name]["feat_choice"] X_train, y_train, Id_train = prep.prepare_lv2_data(feat_choice, "train") X_test, dummy, Id_test = prep.prepare_lv2_data(feat_choice, "test") # X, y, Id = X[:1000,:], y[:1000], Id[:1000] y_pred_test = self._stack_preds_submission(X_train, y_train, X_test, model_name) #Save predictions to csv file with pandas Id_test = np.reshape(Id_test, (Id_test.shape[0],1)) y_pred_test = np.reshape(y_pred_test, (y_pred_test.shape[0], 1)) data = np.hstack((Id_test, y_pred_test)) df = pd.DataFrame(data, columns=["Id", "Response"]) df["Id"] = df["Id"].astype(int) df = df.sort_values("Id") out_name = "./Data/Level2_model_files/submission_%s_stack_with_keras.csv" % model_name df.to_csv(out_name, index = False)
def ensemble_submission(self): """ For all the models specified in self.d_model, train them and apply them on the test data to create a submission file """ # Loop over possible ensemblers for model_name in self.d_model.keys(): # Only train if desired if self.d_model[model_name]["train"]: # Get data feat_choice = self.d_model[model_name]["feat_choice"] X_train, y_train, Id_train = prep.prepare_lv2_data( feat_choice, "train") X_test, dummy, Id_test = prep.prepare_lv2_data( feat_choice, "test") # X, y, Id = X[:1000,:], y[:1000], Id[:1000] y_pred_test = self._stack_preds_submission( X_train, y_train, X_test, model_name) #Save predictions to csv file with pandas Id_test = np.reshape(Id_test, (Id_test.shape[0], 1)) y_pred_test = np.reshape(y_pred_test, (y_pred_test.shape[0], 1)) data = np.hstack((Id_test, y_pred_test)) df = pd.DataFrame(data, columns=["Id", "Response"]) df["Id"] = df["Id"].astype(int) df = df.sort_values("Id") out_name = "./Data/Level2_model_files/submission_%s_stack_with_keras.csv" % model_name df.to_csv(out_name, index=False)
def ensemble(self): """ For all the models specified in self.d_model, train them and estimate the CV score """ # Loop over possible ensemblers for model_name in self.d_model.keys() : # Only train if desired if self.d_model[model_name]["train"]: # Get data feat_choice = self.d_model[model_name]["feat_choice"] X, y, Id = prep.prepare_lv2_data(feat_choice, "train") self._stack_preds(X, y, Id, model_name)
def ensemble(self): """ For all the models specified in self.d_model, train them and estimate the CV score """ # Loop over possible ensemblers for model_name in self.d_model.keys(): # Only train if desired if self.d_model[model_name]["train"]: # Get data feat_choice = self.d_model[model_name]["feat_choice"] X, y, Id = prep.prepare_lv2_data(feat_choice, "train") self._stack_preds(X, y, Id, model_name)