def main(): train, test = utils.load_data() train, test = utils.engineer_stats(train, test) train, test = utils.engineer_features(train, test) X_train = train.drop(['id', 'target'], axis=1).values y_train = train.target.values X_test = test.drop('id', axis=1).values # Train Data params = { 'max_depth': 10, 'max_features': 'sqrt', 'min_samples_split': 100, 'min_samples_leaf': 50, 'n_estimators': 800, 'n_jobs': -1, 'oob_score': False, 'random_state': SEED } model = ExtraTreesClassifier(**params) # Start trainning print('Ready to train with:') print('Model name ', MODEL_NAME) print('Model parameters ', model) print('X_train shape is', X_train.shape) print('y_train shape is', y_train.shape) print('X_test shape is', X_test.shape) layer1.make_oof(model, X_train, y_train, X_test, MODEL_NAME)
def train(self): combined = utils.load_data() if self.drop_stupid: combined = utils.drop_stupid(combined) # if self.bojan_features: # combined = utils.bojan_engineer(combined) if self.engineer_stats: combined = utils.engineer_stats(combined) if self.recon_category: combined = utils.recon_category(combined) if self.cat_transform: combined = utils.cat_transform(combined, self.cat_transform) if self.data_transform: combined = utils.data_transform(combined, self.data_transform) if self.feature_interactions: combined = utils.feature_interactions(combined) if self.kinetic_feature: combined = pd.concat([ combined, pd.read_csv('data/kinetic_combined.csv', index_col='id') ], axis=1) if self.my_features: calc = utils.load_data() calc = calc[calc.columns[calc.columns.str.contains('calc')]] calc = pd.get_dummies(calc, columns=calc.columns) calc = calc[[ 'ps_calc_02_0.0', 'ps_calc_02_0.1', 'ps_calc_05_3', 'ps_calc_06_7', 'ps_calc_06_10', 'ps_calc_07_5', 'ps_calc_08_8', 'ps_calc_08_10', 'ps_calc_10_8', 'ps_calc_11_5', 'ps_calc_11_7', 'ps_calc_11_8' ]] combined = pd.concat([combined, calc], axis=1) train, test = utils.recover_train_test_na(combined, fillna=self.fillna) X_train = train.drop('target', axis=1) y_train = train.target X_test = test # Start trainning print('Ready to train with:') print('Model name ', self.MODEL_NAME) print('Model parameters ', self.model) print('X_train shape is', X_train.shape) print('y_train shape is', y_train.shape) print('X_test shape is', X_test.shape) self.make_oof(self.model, self.params, X_train, y_train, X_test, self.MODEL_NAME)
def train(self): log_path = os.path.join(LOG_PATH, self.MODEL_NAME + '_log.txt') orig_stdout = sys.stdout f = open(log_path, 'w') sys.stdout = f combined = utils.load_data() if self.kinetic_transform: combined = utils.kinetic_transform(combined) if self.drop_stupid: combined = utils.drop_stupid(combined, type=self.drop_stupid) if self.engineer_stats: combined = utils.engineer_stats(combined) if self.recon_category: combined = utils.recon_category(combined) if self.cat_transform: if self.cat_transform != 'smooth': combined = utils.cat_transform(combined, type=self.cat_transform) if self.data_transform: combined = utils.data_transform(combined, type=self.data_transform) if self.feature_interactions: combined = utils.feature_interactions(combined) train, test = utils.recover_train_test_na( combined, remove_outliers=self.remove_outliers) X_train = train.drop('target', axis=1) y_train = train.target X_test = test # Start trainning print('Ready to train with:') print('Model name ', self.MODEL_NAME) print('Model parameters ', self.model.get_params()) print('X_train shape is', X_train.shape) print('y_train shape is', y_train.shape) print('X_test shape is', X_test.shape) self.make_oof(self.model, X_train, y_train, X_test, self.MODEL_NAME) sys.stdout = orig_stdout f.close()
from keras.models import Sequential, Model from keras.layers import Input, Dense, Dropout, Activation, Reshape, Concatenate, Merge from keras.layers.normalization import BatchNormalization from keras.callbacks import EarlyStopping, ModelCheckpoint, Callback, CSVLogger from keras.wrappers.scikit_learn import KerasClassifier from keras.optimizers import SGD from keras.layers.embeddings import Embedding np.random.seed(88) # for reproducibility MODEL_NAME = 'keras_smooth_itt' SEED = 88 combined = utils.load_data() # combined = utils.bojan_engineer(combined) combined = utils.drop_stupid(combined) combined = utils.engineer_stats(combined) combined = utils.recon_category(combined) combined = utils.minmaxpandas(combined) combined = combined.replace(np.NaN, -1) # combined = utils.cat_transform(combined, 'onehot') # combined = utils.data_transform(combined, self.data_transform) # combined = utils.feature_interactions(combined) train, test = utils.recover_train_test_na(combined, fillna=False) X_train = train.drop('target', axis=1) y_train = train.target # X_test = test print('\n')