Skip to content

Instantly share code, notes, and snippets.

@caiobvilar
Created December 3, 2019 14:05
Show Gist options
  • Save caiobvilar/c9cffacf2e5b89551006f325ab3ae84f to your computer and use it in GitHub Desktop.
Save caiobvilar/c9cffacf2e5b89551006f325ab3ae84f to your computer and use it in GitHub Desktop.
X,y = df_hist.iloc[:,1:],df_hist.iloc[:,1]
X_train, X_test, y_train, y_test = train_test_split(X,y,test_size=0.2,random_state=42)
DM_train = xgb.DMatrix(data=X_train, label=y_train)
DM_test = xgb.DMatrix(data=X_test, label=y_test)
params = {"booster":"gblinear", "objective":"reg:linear"}
xg_reg = xgb.train(params=params, dtrain=DM_train, num_boost_round=10)
preds = xg_reg.predict(DM_test)
rmse = np.sqrt(mean_squared_error(y_test,preds))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment