Logistic 回归中正则化强度的倒数是多少?它应该如何影响我的代码? [英] What is the inverse of regularization strength in Logistic Regression? How should it affect my code?

查看:20
本文介绍了Logistic 回归中正则化强度的倒数是多少?它应该如何影响我的代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 sklearn.linear_model.LogisticRegressionscikit learn 中运行逻辑回归.

I am using sklearn.linear_model.LogisticRegression in scikit learn to run a Logistic Regression.

C : float, optional (default=1.0) Inverse of regularization strength;
    must be a positive float. Like in support vector machines, smaller
    values specify stronger regularization.

C 在这里简单来说是什么意思?什么是正则化强度?

What does C mean here in simple terms please? What is regularization strength?

推荐答案

正则化 正在对增加参数值的大小施加惩罚,以减少 过度拟合.当您训练诸如逻辑回归模型之类的模型时,您正在选择最适合数据的参数.这意味着尽量减少模型对给定数据的因变量预测值与因变量实际值之间的误差.

Regularization is applying a penalty to increasing the magnitude of parameter values in order to reduce overfitting. When you train a model such as a logistic regression model, you are choosing parameters that give you the best fit to the data. This means minimizing the error between what the model predicts for your dependent variable given your data compared to what your dependent variable actually is.

当你有很多参数(很多自变量)但没有太多数据时,问题就来了.在这种情况下,模型通常会根据数据中的特性定制参数值——这意味着它几乎完美地适合您的数据.但是,由于这些特性不会出现在您看到的未来数据中,因此您的模型预测效果不佳.

The problem comes when you have a lot of parameters (a lot of independent variables) but not too much data. In this case, the model will often tailor the parameter values to idiosyncrasies in your data -- which means it fits your data almost perfectly. However because those idiosyncrasies don't appear in future data you see, your model predicts poorly.

为了解决这个问题,并像已经讨论过的那样最小化误差,您可以添加最小化的内容并最小化一个惩罚大参数值的函数.最常见的函数是 λΣθj2,它是某个常数 λ 乘以平方参数值 θj2.λ 越大,参数增加幅度的可能性就越小,只是为了调整数据中的小扰动.但是,在您的情况下,您不是指定 λ,而是指定 C=1/λ.

To solve this, as well as minimizing the error as already discussed, you add to what is minimized and also minimize a function that penalizes large values of the parameters. Most often the function is λΣθj2, which is some constant λ times the sum of the squared parameter values θj2. The larger λ is the less likely it is that the parameters will be increased in magnitude simply to adjust for small perturbations in the data. In your case however, rather than specifying λ, you specify C=1/λ.

这篇关于Logistic 回归中正则化强度的倒数是多少?它应该如何影响我的代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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