sklearn"RidgeClassifier"是什么?做? [英] What does sklearn "RidgeClassifier" do?

查看:169
本文介绍了sklearn"RidgeClassifier"是什么?做?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图了解 sklearn.linear_model 中的 RidgeClassifier LogisticRegression 之间的区别.我在文档中找不到它.

I'm trying to understand the difference between RidgeClassifier and LogisticRegression in sklearn.linear_model. I couldn't find it in the documentation.

我想我很清楚 LogisticRegression 的作用.它计算系数和截距以最小化系数平方和的一半 + C 乘以二元交叉熵损失,其中 C 是正则化参数.我从头开始检查了一个简单的实现,结果是一致的.

I think I understand quite well what the LogisticRegression does.It computes the coefficients and intercept to minimise half of sum of squares of the coefficients + C times the binary cross-entropy loss, where C is the regularisation parameter. I checked against a naive implementation from scratch, and results coincide.

RidgeClassifier的结果有所不同,我不知道该如何计算系数和截距?在查看Github代码时,我没有足够的经验来解开它.

Results of RidgeClassifier differ and I couldn't figure out, how the coefficients and intercept are computed there? Looking at the Github code, I'm not experienced enough to untangle it.

我问的原因是,我喜欢RidgeClassifier的结果-它可以更好地概括我的问题.但是在我使用它之前,我至少想知道它是从哪里来的.

The reason why I'm asking is that I like the RidgeClassifier results -- it generalises a bit better to my problem. But before I use it, I would like to at least have an idea where does it come from.

感谢您的帮助.

推荐答案

RidgeClassifier() 的工作方式不同于

RidgeClassifier() works differently compared to LogisticRegression() with l2 penalty. The loss function for RidgeClassifier() is not cross entropy.

RidgeClassifier()使用 Ridge() 回归模型,可以通过以下方式创建分类器:

RidgeClassifier() uses Ridge() regression model in the following way to create a classifier:

为了简单起见,我们考虑使用二进制分类.

Let us consider binary classification for simplicity.

  1. 根据目标变量所属的类将其转换为 +1 -1 .

构建一个 Ridge()模型(这是一个回归模型)以预测我们的目标变量.损失函数为 MSE + l2罚金

Build a Ridge() model (which is a regression model) to predict our target variable. The loss function is MSE + l2 penalty

如果 Ridge()回归的预测值(基于

If the Ridge() regression's prediction value (calculated based on decision_function() function) is greater than 0, then predict as positive class else negative class.

用于多类别分类:

  1. 使用 LabelBinarizer() 创建一个多输出回归方案,然后训练独立的 Ridge()回归模型,每个模型一个(One-Vs-Rest建模)).

  1. Use LabelBinarizer() to create a multi-output regression scenario, and then train independent Ridge() regression models, one for each class (One-Vs-Rest modelling).

从每个类的 Ridge()回归模型(每个类的实数)中获取预测,然后使用 argmax 来预测该类.

Get prediction from each class's Ridge() regression model (a real number for each class) and then use argmax to predict the class.

这篇关于sklearn"RidgeClassifier"是什么?做?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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