使用Gridsearch进行岭回归

时间:2019-12-27 06:20:07

标签: python machine-learning regression data-science grid-search

我尝试使用Gridsearch建立岭回归模型。我得到两个分数值。有人可以解释这两个分数的差异吗,这两个值之间的我的岭回归表现分数是多少?

from sklearn.linear_model import Ridge
ridge_reg = Ridge()
from sklearn.model_selection import GridSearchCV
params_Ridge = {'alpha': [1,0.1,0.01,0.001,0.0001,0] , "fit_intercept": [True, False]}
Ridge_GS = GridSearchCV(ridge_reg, param_grid=params_Ridge)
Ridge_GS.fit(x_train,y_train)
Ridge_GS.best_params_
#*{'alpha': 1, 'fit_intercept': True}*

Ridge_GS.score(x_test,y_test)

0.9113458106264926 这个分数是我从上述代码中获得的。.

这是我尝试的第二种方式

ridge_model = Ridge(random_state=3, **Ridge_GS.best_params_)
ridge_model.fit(x_test,y_test)
ridge_model.score(x_test,y_test)

0.9532468692139026我从第二种方法获得的分数。

0 个答案:

没有答案