Skip to content

Instantly share code, notes, and snippets.

@Shikhargupta
Created May 12, 2020 13:54
Show Gist options
  • Select an option

  • Save Shikhargupta/a3d476e19d36d7c02f0d4de6403c0469 to your computer and use it in GitHub Desktop.

Select an option

Save Shikhargupta/a3d476e19d36d7c02f0d4de6403c0469 to your computer and use it in GitHub Desktop.
X_train, X_test, y_train, y_test = train_test_split(X_train, y_train, test_size=0.2, random_state=0)
xg_reg = xgb.XGBRegressor(base_score=0.5, colsample_bylevel=1, colsample_bytree=0.4,
gamma=0, learning_rate=0.07, max_delta_step=0, max_depth=3,
min_child_weight=1.5, missing=None, n_estimators=400, nthread=-1,
objective='reg:linear', reg_alpha=0.75, reg_lambda=0.45,
scale_pos_weight=1, seed=42, silent=True, subsample=0.6)
xg_reg.fit(X_train,np.log(y_train))
y_pred = np.exp(xg_reg.predict(X_test))
print('Root Mean Squared Error:', np.sqrt(metrics.mean_squared_error(np.log(y_test), np.log(y_pred))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment