text_plain_output_1.png
from sklearn.model_selection import train_test_split

from sklearn.preprocessing import OrdinalEncoder

from tpot import TPOTRegressor

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']
features = train.drop(['target'], axis=1)
X = features.copy()
X_test = test.copy()
categorical_cols = [cname for cname in features.columns if features[cname].dtype == 'object']
numerical_cols = [cname for cname in features.columns if features[cname].dtype in ['int64', 'float64']]
my_cols = categorical_cols + numerical_cols

ordinal_encoder = OrdinalEncoder()
X[categorical_cols] = ordinal_encoder.fit_transform(features[categorical_cols])
X_test[categorical_cols] = ordinal_encoder.transform(test[categorical_cols])
X_train, X_valid, y_train, y_valid = train_test_split(X, y, train_size=0.8, test_size=0.2, random_state=17)

scoring_function = 'accuracy'
tpot_rgr = TPOTRegressor(scoring=scoring_function, verbosity=2, random_state=42, cv=5, n_jobs=-1)
tpot_rgr.fit(X_train, y_train)
print(tpot_rgr.score(X_valid, y_valid))