text_plain_output_1.png
from sklearn.model_selection import GridSearchCV

from sklearn.model_selection import train_test_split

import pandas as pd

import xgboost as xgb

train = pd.read_csv('../input/30-days-of-ml/train.csv', index_col=0)
test = pd.read_csv('../input/30-days-of-ml/test.csv', index_col=0)
sub = pd.read_csv('/kaggle/input/30-days-of-ml/sample_submission.csv')

y = train.target
X_all = pd.get_dummies(train.drop(['target'], axis=1).append(test)).copy()
X, X_test = (X_all[:300000], X_all[300000:])

from sklearn.model_selection import train_test_split
X_train, X_valid, y_train, y_valid = train_test_split(X[:5000], y[:5000], test_size=0.2, random_state=42)

import xgboost as xgb
from sklearn.model_selection import GridSearchCV
params = {'max_depth': [2], 'gamma': [0], 'eta': [0], 'subsample': [0.8], 'colsample_bytree': [0.8], 'colsample_bylevel': [1.0], 'n_estimators': [1200]}
model = xgb.XGBRFRegressor(eval_metric='rmse', random_state=42, verbosity=1)
cv = GridSearchCV(model, params, cv=5)

cv.fit(X_train, y_train)

cv.best_estimator_

y_train_pred = cv.predict(X_train)
y_valid_pred = cv.predict(X_valid)
print(len(y_train_pred), len(y_valid_pred))