text_plain_output_1.png
from sklearn.compose import make_column_transformer

from sklearn.ensemble import RandomForestRegressor

from sklearn.linear_model import LinearRegression

from sklearn.model_selection import cross_val_score

from sklearn.pipeline import make_pipeline

from sklearn.preprocessing import StandardScaler,OneHotEncoder

from sklearn.tree import DecisionTreeRegressor

import numpy as np # linear algebra

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

TRAIN_DATA = '/kaggle/input/cais-exec-team-in-house/train.csv'
SUBMISSIONS_DATA = '/kaggle/input/cais-exec-team-in-house/sampleSubmission.csv'
TEST_DATA = '/kaggle/input/cais-exec-team-in-house/test.csv'
df = pd.read_csv(TRAIN_DATA, index_col='id')
test_df = pd.read_csv(TEST_DATA, index_col='id')
sub_df = pd.read_csv(SUBMISSIONS_DATA, index_col='id')

numerics = ['int16', 'int32', 'int64', 'float16', 'float32', 'float64']
num_attribs = list(df.select_dtypes(include=numerics))
num_attribs.remove('grade')
cat_attribs = list(df.select_dtypes(exclude=numerics))
num_pipline = make_pipeline(StandardScaler())
full_pipeline = make_column_transformer((num_pipline, num_attribs), (OneHotEncoder(), cat_attribs))
X = df.drop(columns='grade')
full_pipeline = full_pipeline.fit(X)
X = full_pipeline.transform(X)
y = df.grade

from sklearn.model_selection import cross_val_score
from sklearn.tree import DecisionTreeRegressor
from sklearn.ensemble import RandomForestRegressor
models = [LinearRegression(), DecisionTreeRegressor(), RandomForestRegressor()]
for model in models:
    scores = cross_val_score(model, X, y, scoring='neg_mean_squared_error', cv=5)
    real_scores = np.sqrt(-scores)
    print(f'The scores for {model.__class__.__name__} were {real_scores} and the average was {np.average(real_scores)}')
    print('-------------------------------------------------')