Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# training a Decision Tree model
from sklearn.tree import DecisionTreeRegressor
# measuring RMSE score
from sklearn.metrics import mean_squared_error
# Decision tree
dt = DecisionTreeRegressor(max_depth=10,random_state=27)
rmse = []
# raw, normalized and standardized training and testing data
trainX = [X_train,X_train_norm,X_train_stand]
testX = [X_test,X_test_norm,X_test_stand]
# model fitting and measuring RMSE
for i in range(len(trainX)):
# fit
dt.fit(trainX[i],y_train)
# predict
pred = dt.predict(testX[i])
# RMSE
rmse.append(np.sqrt(mean_squared_error(y_test,pred)))
# visualizing the result
df_dt = pd.DataFrame({'RMSE':rmse},index=['Original','Normalized','Standardized'])
df_dt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment