text_html_output_1.png
from lightgbm import LGBMRegressor

from sklearn.compose import ColumnTransformer

from sklearn.model_selection import KFold

from sklearn.model_selection import cross_validate, cross_val_predict

from sklearn.pipeline import Pipeline

from sklearn.preprocessing import OneHotEncoder, StandardScaler

from sklearn.preprocessing import OrdinalEncoder

import numpy as np

import pandas as pd

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)

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

categorical_cols = [col for col in X.columns if 'cat' in col]
numerical_cols = [col for col in X.columns if 'cont' in col]
numerical_transformer = StandardScaler()
categorical_transformer = OrdinalEncoder(handle_unknown='ignore', dtype=np.int)
preprocessor = ColumnTransformer(transformers=[('num', numerical_transformer, numerical_cols), ('cat', categorical_transformer, categorical_cols)])

model = LGBMRegressor(device='gpu', gpu_platform_id=0, gpu_device_id=0)

pipeline = Pipeline(steps=[('preprocessor', preprocessor), ('model', model)])

kfold = KFold(n_splits=5, shuffle=True, random_state=42)
results = cross_validate(pipeline, X=X, y=y, cv=kfold, scoring='neg_root_mean_squared_error', n_jobs=-1)
print('RMSE: %f (%f)' % (-results['test_score'].mean(), results['test_score'].std()))