This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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