如何使用 scikit 计算调整后的 R2 值 [英] How to calculated the adjusted R2 value using scikit

查看:66
本文介绍了如何使用 scikit 计算调整后的 R2 值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据集,我必须为其开发各种模型并计算所有模型的调整后的 R2 值.

I have a dataset for which I have to develop various models and compute the adjusted R2 value of all models.

    cv = KFold(n_splits=5,shuffle=True,random_state=45)
    r2 = make_scorer(r2_score)
    r2_val_score = cross_val_score(clf, x, y, cv=cv,scoring=r2)
    scores=[r2_val_score.mean()]
    return scores

我已经使用上面的代码计算了每个模型的 R2 值.但我更想知道每个模型的调整后的 R2 值python中有没有可以完成这项工作的包?

I have used the above code to calculate the R2 value of every model. But I am more interested to know the adjusted R2 value of every models Is there any package in python which can do the job?

感谢您的帮助.

推荐答案

您可以使用给定的简单公式从 R2 计算调整后的 R2 这里.

you can calculate the adjusted R2 from R2 with a simple formula given here.

Adj r2 = 1-(1-R2)*(n-1)/(n-p-1)

调整后的 R2 也需要多个自变量.这就是为什么不会使用此函数计算它的原因.

Adjusted R2 requires number of independent variables as well. That's why it will not be calculated using this function.

这篇关于如何使用 scikit 计算调整后的 R2 值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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