text_plain_output_1.png
from sklearn.metrics import mean_squared_error

from sklearn.metrics import mean_squared_error

from sklearn.preprocessing import OrdinalEncoder

from xgboost import XGBRegressor

import numpy as np # linear algebra

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

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)

train.shape

train.info

y = train['target']
features = train.drop(['target'], axis=1)

col_data = []
for col in features.columns:
    if 'cat' in col:
        col_data.append(col)
X = features.copy()
X_test = test.copy()
ordinal_encoder = OrdinalEncoder()
X[col_data] = ordinal_encoder.fit_transform(features[col_data])
X_test[col_data] = ordinal_encoder.transform(test[col_data])

from sklearn.metrics import mean_squared_error
from xgboost import XGBRegressor
model = XGBRegressor()
model.fit(X_train, y_train)
preds = model.predict(X_valid)

sub = pd.read_csv('/kaggle/input/30-days-of-ml/sample_submission.csv')

model.fit(X, y)
preds = model.predict(X_test)

sub.target = preds

sub.to_csv('submission.csv', index=False)
print('Saved')