如何解决为什么我的 SVR 模型给出的 r2_score 为 0,而线性回归和 xgboost 在相同数据上给出 0.7 和 0.8
我已经预处理了我的数据并在我的数据上拟合了各种模型,以查看每个模型的性能。我的代码:
# standardize the data using Robust Scaler
rc = RobustScaler()
X_train = rc.fit_transform(X_train)
X_test = rc.transform(X_test)
使用线性回归模型
regr = LinearRegression()
regr.fit(X_train,y_train)
train_score = regr.score(X_train,y_train)
#print training score
print("training score: ",np.round(train_score,2))
# making predictions on test data
y_pred_test=regr.predict(X_test)
test_score = regr.score(X_test,y_test)
print("test score:",np.round(test_score,2))
给出输出
training score: 0.73
test score: 0.74
XGBoost
from xgboost import XGBRegressor
model = XGBRegressor()
model.fit(X_train,y_train)
train_score = model.score(X_train,y_train)
print("training score: ",2))
# making predictions on test data
y_pred_test=model.predict(X_test)
test_score = model.score(X_test,2))
给出输出
training score: 0.89
test score: 0.82
当我尝试使用 SVR 模型时
# fitting SVR model
svr = SVR(kernel = 'rbf')
svr.fit(X_train,y_train)
y_pred_train = svr.predict(X_train)
train_score = svr.score(X_train,y_train)
#print training score
print("training score: ",2))
# making predictions on test data
y_pred_test=svr.predict(X_test)
test_score = svr.score(X_test,2))
我的输出
training score: -0.0
test score: -0.0
我不明白为什么我的 svr 模型给出了 0 分。即使它在一定程度上表现不佳,我也希望分值会下降但不会是 0。我可能哪里出错了?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。