sklearn LogisticRegression 没有正则化 [英] sklearn LogisticRegression without regularization

查看:41
本文介绍了sklearn LogisticRegression 没有正则化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

sklearn 中的逻辑回归类带有 L1 和 L2 正则化.如何关闭正则化以获得原始"逻辑拟合,例如 Matlab 中的 glmfit?我想我可以设置 C = 大数,但我不认为这是明智的.

Logistic regression class in sklearn comes with L1 and L2 regularization. How can I turn off regularization to get the "raw" logistic fit such as in glmfit in Matlab? I think I can set C = large number but I don't think it is wise.

查看文档以获取更多详细信息http://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html#sklearn.linear_model.LogisticRegression

see for more details the documentation http://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html#sklearn.linear_model.LogisticRegression

推荐答案

是的,选择尽可能大的数字.在正则化中,代价函数包含一个正则化表达式,请记住,sklearn 正则化中的 C 参数是正则化强度的倒数.

Yes, choose as large a number as possible. In regularization, the cost function includes a regularization expression, and keep in mind that the C parameter in sklearn regularization is the inverse of the regularization strength.

C 在这种情况下是 1/lambda,条件是 C >0.

C in this case is 1/lambda, subject to the condition that C > 0.

因此,当 C 接近无穷大时,lambda 接近 0.当这种情况发生时,成本函数就变成了标准误差函数,因为正则化表达式就所有意图和目的而言都变成了 0.

Therefore, when C approaches infinity, then lambda approaches 0. When this happens, then the cost function becomes your standard error function, since the regularization expression becomes, for all intents and purposes, 0.

这篇关于sklearn LogisticRegression 没有正则化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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