如何解决为什么 LightGBM 回归 R 平方值是负的?
根据下面的代码,我得到了一个负的r2分值,那是为什么? 当我试图
in_data_in_leaf=0,min_sum_hessian_in_leaf=0.0 this code,r2 score can ben acquired positive and strong but in this time SHAP plot shows all value as a ZERO.
这是一个数据链接:https://github.com/kilickursat/Tunnelling/blob/main/TBM_Performance.xlsx
import pandas as pd
from lightgbm import LGBMRegressor
import shap
# import the data
df = pd.read_excel('TBM_Performance.xlsx')
df['ROCK_PRO'] = df['UCS(MPa)'] / df['BTS(MPa)']
print(df.shape[0])
# 18
# extract the features and target
X = df[['UCS(MPa)','BTS(MPa)','Fs(m)','Alpha(degree)','PI(kN/mm)','ROCK_PRO']]
y = df[['ROP(m/hr)']]
# train the model with min_data_in_leaf=20
hyper_params = {
'task': 'train','boosting_type': 'goss','objective': 'regression','metric': 'mse',}
model = LGBMRegressor(**hyper_params).fit(X,y)
print(model.predict(X))
# [2.52277776 2.52277776 2.52277776 2.52277776 2.52277776 2.52277776
# 2.52277776 2.52277776 2.52277776 2.52277776 2.52277776 2.52277776
# 2.52277776 2.52277776 2.52277776 2.52277776 2.52277776 2.52277776]
# train the model with min_data_in_leaf=3
hyper_params = {
'task': 'train','min_data_in_leaf': 3,y)
print(model.predict(X))
# [2.21428748 2.21428748 2.21428748 2.68171691 2.36794282 2.37986215
# 2.37986215 2.77942405 2.84938042 2.84938042 2.8104722 2.8104722
# 2.50056257 2.47946274 2.46754341 2.58446466 2.58446466 2.24212594]
explainer = shap.Explainer(model)
shap_values = explainer(X)
shap.plots.waterfall(shap_values[0])
#R2_SCORE = -0.4
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。