Example #1
0
# We have train, y_train and test
scaler = preprocessing.StandardScaler().fit(train)
train = scaler.transform(train)

# scale test dataset
test = scaler.transform(test)

print('Means = ', scaler.mean_)
print('Standard Deviations = ', scaler.scale_)

## Modeling and Predictions

# L1_cv
l1_cv = LassoCV(cv=5, max_iter=10000)
#100 Regularization coefficients evenly spaced between 0.1 and 1000
l1_cv.alphas = tuple(np.linspace(0.1, 1000, 100))
l1_cv.fit(train, y_train)
res_l1 = l1_cv.predict(test)
print(res_l1)

# L2_cv
l2_cv = RidgeCV(cv=None, store_cv_values=True)
#100 Regularization coefficients evenly spaced between 0.1 and 1000
l2_cv.alphas = tuple(np.linspace(0.1, 10000, 100))
l2_cv.fit(train, y_train)
res_l2 = l2_cv.predict(test)

print(res_l2)

# res_xgb
model_xgb = xgb.XGBRegressor(colsample_bytree=0.2,