Beispiel #1
0
def main():
    combined = utils.load_data()
    combined = utils.drop_stupid(combined)
    combined = utils.cat_transform(combined, type='onehot')

    combined.replace(-1, combined.median(axis=0), inplace=True)
    combined = utils.data_transform(combined, 'log')

    train, test = utils.recover_train_test_na(combined, fillna=False)

    # Prepare X and y following with parsing to numpy datatype
    X_train = train.drop('target', axis=1).values
    y_train = train.target.values
    X_test = test.values

    # Train Data
    params = {
        'class_weight': 'balanced',
        'verbose': 1
    }
    model = LogisticRegression(**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)
Beispiel #2
0
    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)
Beispiel #3
0
    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()
Beispiel #4
0
from keras.models import load_model, Sequential
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')
Beispiel #5
0
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

from tensorflow import set_random_seed
set_random_seed(MODEL_SEED)

np.random.seed(MODEL_SEED)  # for reproducibility
MODEL_NAME = 'keras_joe_itt'
SEED = MODEL_SEED

combined = utils.load_data()
# combined = utils.bojan_engineer(combined)
combined = utils.drop_stupid(combined, 'default')
combined = utils.engineer_stats(combined)
# 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)

# Fillna for minmax scaler
train = train.replace(np.NaN, -1)
test = test.replace(np.NaN, -1)

X_train = train.drop('target', axis=1)
y_train = train.target
X_test = test

col_vals_dict = {