I am working with the DecisionTreeRegressor
and trying to understand how well the data fits the model. I calculated both RMSE
and coefficient of determination
. At a certain depth, coefficient of determination
has the value equal to 0.9918744073066561
but the value of RMSE is equal to 75.0025
. I cannot understand this. The value of RMSE is quite large but the value of the coefficient of determination is close to 1.0. What does it really mean? Is the model/fit good enough?
from sklearn.tree import DecisionTreeRegressor
from sklearn.ensemble import AdaBoostRegressor
from sklearn.metrics import mean_squared_error
def rmse(y_true, y_pred):
return math.sqrt(mean_squared_error(y_true, y_pred))
sample_depth = np.linspace(1,40, num = 40, dtype=int)
dt_score_list = []
for index, depth in enumerate(sample_depth):
boosted_regressor = AdaBoostRegressor(DecisionTreeRegressor(max_depth=depth), random_state=1)
boosted_regressor.fit(X_train, y_train)
dt_score_list.append(boosted_regressor.score(X_test, y_test))
print(boosted_regressor.score(X_test, y_test), rmse(y_test, boosted_regressor.predict(X_test)), depth)