在scikits中使用cross_val_score时保持拟合参数学习 [英] Keep the fitted parameters when using a cross_val_score in scikits learn

查看:104
本文介绍了在scikits中使用cross_val_score时保持拟合参数学习的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用scikits-learn来拟合使用Ridge回归的线性模型.我想做的是使用交叉验证来拟合许多不同的模型,然后查看参数系数以了解它们在不同CV分割中的稳定性. (或者将它们平均在一起).

I'm trying to use scikits-learn to fit a linear model using Ridge regression. What I'd like to do is use cross validation to fit many different models, and then look at the parameter coefficients to see how stable they are across different CV splits. (or perhaps to average them all together).

当我尝试使用交叉验证例程拟合模型时(例如,使用KFold实例和cross_val_score函数),我会获得每个CV分组的得分列表,但我没有获得在每个分割中计算的拟合系数值.我有办法访问此信息吗?很明显,每次迭代都在计算它,因此我认为必须有一种方法可以报告此情况,但我无法弄清楚...

When I try to fit the model with a cross-validation routine (e.g., using an instance of KFold and the cross_val_score function), I get back a list of the scores for each CV split, but I don't get back the fitted coefficient values that were calculated on each split. Is there a way for me to access this information? It's clearly being calculated on each iteration, so I assume there must be a way to report this back but I haven't been able to figure it out...

为澄清起见,我不是在寻找拟合中指定的参数(例如alpha值),而是在回归中寻找拟合的系数值.

to clarify, I'm not looking for the parameters that I specified in the fitting (e.g., alpha values), I'm looking for the fitted coefficient values in the regression.

推荐答案

clf = linear_model.RidgeCV(...) # your own parameters setting
param = clf.get_params(deep=True)

请参见文档了解更多信息.

要获取权重向量系数,请使用clf.coef_.此外,cv_values_alpha_分别是clf返回MSE和估计正则化参数的另外两个属性.

To get the weight vector coefficient, use clf.coef_. Besides, cv_values_ and alpha_ are two other attributes of clf returns MSEs and estimated regularization parameter respectively.

这篇关于在scikits中使用cross_val_score时保持拟合参数学习的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆