Kaggle competition: Don't Overfit! II
<SOS> metric: AUC Kaggle data source: dont-overfit!-ii<prepare_x_and_y>
pd.set_option('display.max_columns', 100)
 pd.set_option('display.max_rows', 100)
scale = sales['scale'].values
ids = sales['id'].values
ys = sales['x'].values
Z = sales[FEATS].values<normalization>
train = pd.read_csv(".. /input/train.csv")
 test = pd.read_csv(".. /input/test.csv" )
sv = scale[val_mask]
se = scale[te_mask]
ids = ids[te_mask]
ids = ids.reshape(( -1, 28))<define_variables>
train = pd.read_csv(".. /input/train.csv")
 test = pd.read_csv(".. /input/test.csv" )
ca = sales[['snap_CA']].values
tx = sales[['snap_TX']].values
wi = sales[['snap_WI']].values
wday = sales[['wday']].values
month = sales[['month']].values
year = sales[['year']].values
event = sales[['event_name']].values
nday = sales[['nday']].values<define_variables>
target_column = 'target'
column_to_drop = 'id'
train_set, validate_set = train_test_split(train, test_size = 0.2, random_state = 1)
 x_train = train_set.drop([target_column, column_to_drop], axis = 1 ).copy()
y_train = train_set[target_column].copy()
x_validate = validate_set.drop([target_column, column_to_drop], axis = 1 ).copy()
y_validate = validate_set[target_column].copy()
x_total = train.drop([target_column, column_to_drop], axis = 1 ).copy()
y_total = train[target_column].copy()
x_test = test.drop(column_to_drop, axis = 1 ).copy()
item = sales[['item_id']].values
dept = sales[['dept_id']].values
cat = sales[['cat_id']].values
store = sales[['store_id']].values
state = sales[['state_id']].values<drop_column>
en = ElasticNet(alpha = 0.085, l1_ratio = 0.5)
 en.fit(x_train, y_train )
def make_data(mask):
x = {"snap_CA":ca[mask], "snap_TX":tx[mask], "snap_WI":wi[mask], "wday":wday[mask],
"month":month[mask], "year":year[mask], "event":event[mask], "nday":nday[mask],
"item":item[mask], "dept":dept[mask], "cat":cat[mask], "store":store[mask],
"state":state[mask], "num":Z[mask]}
t = ys[mask]
return x, t<prepare_x_and_y>
y_validate_p = en.predict(x_validate)
 roc_auc_score(y_validate, y_validate_p )
xt, yt = make_data(tr_mask)
 xv, yv = make_data(val_mask)
 xe, ye = make_data(te_mask )<import_modules>
en = ElasticNet(alpha = 0.085, l1_ratio = 0.5)
 en.fit(x_total, y_total )
<compute_test_metric><EOS> 
submission = pd.DataFrame(test.id)
 y_test_p = pd.Series(en.predict(x_test))
submission['target'] = y_test_p
submission.to_csv("submission.csv", index = False )