代码的预测结果误差有点大


import pandas as pd
from sklearn.tree import DecisionTreeRegressor
from sklearn import preprocessing
from sklearn.metrics import mean_squared_error
from sklearn.model_selection import GridSearchCV
# 读取含有热误差数据的CSV文件
train_file = open('data8.csv', encoding='utf-8')
train_df = pd.read_csv(train_file)
 
# 读取测试集的含有热误差数据的CSV文件
test_file = open('data.csv', encoding='utf-8')
test_df = pd.read_csv(test_file)
 
# 对训练集进行数据预处理
X_train = train_df.iloc[:, :-1]
Y_train = train_df.iloc[:, -1]
X_train_scaled = preprocessing.scale(X_train)
 
# 对测试集进行数据预处理
X_test = test_df.iloc[:, :-1]
Y_test = test_df.iloc[:, -1]
X_test_scaled = preprocessing.scale(X_test, with_mean=X_train_scaled.mean(axis=0)[0], with_std=X_train_scaled.mean(axis=0)[0])
X = pd.concat([test_df.iloc[:, :-1], train_df.iloc[:, :-1]], axis=1)
Y = pd.concat([test_df.iloc[:, -1], train_df.iloc[:, -1]], axis=1)
X_test.columns = X_train.columns

# 创建决策树模型
dt = DecisionTreeRegressor()
 
# 定义网格搜索参数
param_grid = {
    'max_depth': [1,2,3,4,5,6,7,8,9],
    'min_samples_split': [2, 4, 6],
    'min_samples_leaf': [1, 2, 3]
}
# 进行网格搜索优化
grid = GridSearchCV(dt, param_grid, cv=5)
grid.fit(X, Y)
grid_search = GridSearchCV(DecisionTreeRegressor(), param_grid, cv=5)
grid_search.fit(X_train, Y_train)
best_model = grid_search.best_estimator_


# 输出最优参数和模型得分
print('Best Parameters:', grid.best_params_)

# 定义新的温度数据

# 输出预测结果
Y_pred = best_model.predict(X_test)
mse = mean_squared_error(Y_test, Y_pred)
print(f"MSE: {mse:.4f}")
print(Y_pred)
X_test = pd.concat([X_train, X_test], axis=0, ignore_index=True)
 

预测的误差有点大,能不能帮忙降一点

runfile('C:/Users/86191/.spyder-py3/untitled7.py', wdir='C:/Users/86191/.spyder-py3')
Best Parameters: {'max_depth': 8, 'min_samples_leaf': 2, 'min_samples_split': 2}
MSE: 25.0850
[ 8.699       8.699       8.699      17.013      17.013      17.013
 17.013      28.31       28.31       28.31       36.306      36.306
 36.306      36.306      36.306      36.306      36.306      38.764
 38.764      41.458      48.499      48.499      48.499      48.499
 53.0685     53.0685     53.0685     53.0685     53.0685     53.0685
 53.0685     53.0685     53.0685     53.0685     53.0685     53.0685
 53.0685     53.0685     53.0685     53.0685     54.123      54.123
 54.123      54.123      54.123      54.123      54.123      54.123
 54.123      54.123      54.123      54.123      54.123      54.123
 54.123      54.123      54.123      54.808      54.808      54.808
 54.808      54.808      54.808      54.808      54.808      55.543
 56.323      56.133      55.46975    55.46975    55.46975    55.46975
 55.46975    55.31866667 55.31866667 55.31866667 55.31866667 55.31866667
 55.31866667 55.31866667 55.31866667 55.31866667 55.31866667 54.594
 54.594      54.594      54.594      54.594     ]