In this my code I am trying to use GradientBoostingRegressor
-I am confused because I am getting a large Root Mean Squared Error but I am not sure how to evaluate if it is too high.
-How can get on RMSE less than zero?
Any advice, please?
The mean squared error (MSE) on test set: 5.1529
The root mean squared error (RMSE) on test set: 2.2700
import math
import pandas as pd
import csv
import numpy as np
import math
from sklearn.ensemble import GradientBoostingRegressor,RandomForestRegressor
from sklearn.preprocessing import StandardScaler
from sklearn.metrics import mean_squared_error ,mean_absolute_error
from sklearn.model_selection import train_test_split
from sklearn import metrics
from sklearn import datasets
df = datasets.load_boston()
X_train, X_test, y_train, y_test = train_test_split(df.data, df.target, random_state=42, test_size=0.1)
sc = StandardScaler()
X_train = sc.fit_transform(X_train)
X_test = sc.transform(X_test)
gr=GradientBoostingRegressor (n_estimators=1000,
max_depth= 3,
min_samples_split= 5,
learning_rate=0.01,
loss ='ls')
gr.fit(X_train ,y_train )
Y_Pred = gr.predict(X_test )
# Create the mean squared error
mse = mean_squared_error(y_test, gr.predict(X_test))
print("The mean squared error (MSE) on test set: {:.4f}".format(mse))
rmse = math.sqrt(mse)
print("The root mean squared error (RMSE) on test set: {:.4f}".format(rmse))