text_plain_output_1.png
from sklearn.metrics import mean_squared_error

from xgboost import XGBRegressor

import pandas as pd

df_train = pd.read_csv('../input/tabulardata-kfolds-created/train_folds.csv')
df_test = pd.read_csv('../input/tabular-playground-series-aug-2021/test.csv')
sample_submission = pd.read_csv('../input/tabular-playground-series-aug-2021/sample_submission.csv')

useful_features = [c for c in df_train.columns if c not in ('id', 'loss', 'kfold')]
df_train[useful_features]

from xgboost import XGBRegressor
xtrain = df_train[df_train.kfold != 0]
xvalid = df_train[df_train.kfold == 0]
ytrain = xtrain['loss']
xtrain = xtrain[useful_features]
yvalid = xvalid['loss']
xvalid = xvalid[useful_features]
model = XGBRegressor(n_estimators=500, random_state=0)
model.fit(xtrain, ytrain, early_stopping_rounds=5, eval_set=[(xvalid, yvalid)], verbose=False)
preds_valid = model.predict(xvalid)
print(mean_squared_error(yvalid, preds_valid, squared=False))