This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from xgboost import plot_importance | |
from matplotlib import pyplot | |
xgb_regr = xgb.XGBRegressor( | |
colsample_bytree=0.2, | |
gamma=0.0, | |
learning_rate=0.01, | |
max_depth=4, | |
min_child_weight=1.5, | |
n_estimators=7200, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# creating matrices for sklearn: | |
x_train = np.array(train_df_munged) | |
x_test = np.array(test_df_munged) | |
y_train = label_df.values | |
ntrain = x_train.shape[0] | |
ntest = x_test.shape[0] | |
kf = KFold(ntrain, n_folds=NFOLDS, shuffle=True, random_state=SEED) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
y_final = (1*np.ravel(y_test_pred_xgb) + 1*np.ravel(y_test_pred_kridge) + 1*np.ravel(y_test_pred_lasso))/3 | |
y_final.shape | |
y_pred = np.exp(y_final) | |
# Final Conversion. | |
output_file = 'xgboost_lasso_kridge_weights_1_1_1' | |
final_file = '0108_'+ output_file +'.csv' | |
pred_df = pd.DataFrame(y_pred, index=test_df["Id"], columns=["SalePrice"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Kernel Ridge GridSearch | |
from sklearn.kernel_ridge import KernelRidge | |
kridge_grid = KernelRidge() | |
parameter_grid = {'alpha': [0.0001,0.001,0.01,0.1], | |
'degree': [1,2,3,4], | |
'kernel': ['polynomial'] | |
#'n_estimators': [200,210,240,250], | |
#'min_child_weight': [1,2,3,4] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
train_df["New_House"] = (train_df["YearRemodAdd"] == train_df["YrSold"]) * 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
train_df["Aggregate_OverallQual"] = train_df.OverallQual.replace( | |
{1 : 1, 2 : 1, 3 : 1, 4 : 2, 5 : 2, 6 : 2, 7 : 3, 8 : 3, 9 : 3, 10 : 3}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
train_df["Is_Electrical_SBrkr"] = (df["Electrical"] == "SBrkr") * 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dummies = pd.get_dummies(train_df[column_name], prefix = "_" + column_name) | |
train_df = train_df.join(dummies) | |
train_df = train_df.drop([column_name], axis=1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
quality_dict = {None: 0, "Po": 1, "Fa": 2, "TA": 3, "Gd": 4, "Ex": 5} | |
train_df["ExterQual"] = df["ExterQual"].map(quality_dict).astype(int) | |
train_df["ExterCond"] = df["ExterCond"].map(quality_dict).astype(int) | |
train_df["BsmtQual"] = df["BsmtQual"].map(quality_dict).astype(int) | |
train_df["BsmtCond"] = df["BsmtCond"].map(quality_dict).astype(int) | |
train_df["HeatingQC"] = df["HeatingQC"].map(quality_dict).astype(int) | |
train_df["KitchenQual"] = df["KitchenQual"].map(quality_dict).astype(int) | |
train_df["FireplaceQu"] = df["FireplaceQu"].map(quality_dict).astype(int) | |
train_df["GarageQual"] = df["GarageQual"].map(quality_dict).astype(int) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
all_df["CentralAir"] = (df["CentralAir"] == "Y") * 1.0 |