How to calculated the adjusted R2 value using scikit

三世轮回 提交于 2020-05-25 07:34:10

问题


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

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?

I will appreciate your help.


回答1:


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

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

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



来源:https://stackoverflow.com/questions/51038820/how-to-calculated-the-adjusted-r2-value-using-scikit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!