<jupyter_start><jupyter_text>save cleaned dataset as another .csv fileautomotive = automotive.to_csv('automotive.csv', index=False)<jupyter_code>automotive.head()
# define features and target
X = automotive.drop(columns=['mpg', 'car name'], axis=1)
y = automotive['mpg']
# split data into train-test set
from sklearn.model_selection import train_test_split

# train-test split 80-20
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
# import DecisionTreeRegressor
from sklearn.tree import DecisionTreeRegressor
# instantiate DecisionTreeRegressor (dtr) with max_depth of 8 and min_samples_leaf of 0.13
dtr = DecisionTreeRegressor(max_depth=8, min_samples_leaf=0.13)
# fit training data into model
dtr.fit(X_train, y_train)
# predict test set labels
y_pred = dtr.predict(X_test)
print(y_pred[0:5])
# metric used for evaluation: mean squared error
# import mean squared error
from sklearn.metrics import mean_squared_error as MSE
# compute mean squared error of model with test set
mse_dtr = MSE(y_test, y_pred)
# compute root mean squared error of dtr
rmse_dtr = mse_dtr**(1/2)
# print output of rmse_dtr
print(f"Test set RMSE of dtr: {rmse_dtr:.2f}")<jupyter_output>Test set RMSE of dtr: 4.18
{'fraction_non_alphanumeric': 0.09334415584415584, 'fraction_numerical': 0.020292207792207792, 'mean_word_length': 6.383233532934132, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '254085', 'license': 'MIT', 'n_tokens_mistral': 461, 'n_tokens_neox': 425, 'n_words': 127, 'path': 'workshops/decision-trees/DecisionTreeRegressor.ipynb', 'repo_name': 'dianeyeo/aiig-suss', 'size': '1232'}