python中alpha和lambda正则化参数的问题 [英] problem with alpha and lambda regularization parameters in python

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

问题描述

问题:Logistic Regression 使用 alpha = 0.1 训练具有 L1 正则化和 L2 正则化的逻辑回归模型和 λ = 0.1.报告准确率、准确率、召回率、f1-score 并打印混淆矩阵

我的代码是:

_lambda = 0.1c = 1/_lambda分类器 = LogisticRegression(penalty='l1',C=c)分类器.fit(X_train,y_train)y_pred = 分类器.预测(X_test)

我不知道 alpha 和 lambda 的真正位置在哪里.我做对了吗?

解决方案

你的例子

alpha=0, lambda=10 (AKA .1/1)

阿尔法

alpha 是增加特征数量惩罚以控制过拟合的参数,在这种情况下是 L1(套索回归)或 L2(岭回归).L1 和 L2 惩罚不能同时进行,因为只有一个 Lambda 系数.顺便说一句 - Elastic Net 是一个介于 L1 和 L2 之间的 alpha 参数,例如,如果您使用 sklearn.SGD_Regressor() alpha=0 是 L1 alpha=0.5 是 elasticnet,alpha=1 是 Ridge.

Lambda

是控制学习率的术语.换句话说,您希望模型在每次学习迭代中做出多少改变.

混乱

更糟糕的是,这些术语经常互换使用,我认为是由于图论、统计理论、数学理论以及编写常用机器学习库的个人不同但相似的概念

在这里查看一些信息:https://www.analyticsvidhya.com/blog/2016/01/complete-tutorial-ridge-lasso-regression-python/ 但也可以寻找一些关于统计学习的免费学术教科书.

Question : Logistic Regression Train logistic regression models with L1 regularization and L2 regularization using alpha = 0.1 and lambda = 0.1. Report accuracy, precision, recall, f1-score and print the confusion matrix

My code is :

_lambda = 0.1
c = 1/_lambda
classifier = LogisticRegression(penalty='l1',C=c)
classifier.fit(X_train, y_train)

y_pred = classifier.predict(X_test)

I don't know where is really location of alpha and lambda. Did I work right?

解决方案

your example

alpha=0, lambda=10 (AKA .1/1)

alpha

alpha is the parameter that adds penalty for number of features to control overfitting, in this case either L1 (Lasso Regression) or L2 (Ridge Regression). L1 and L2 penalty cannot both be done at the same time, as there is only one Lambda coefficient. Quick aside - Elastic Net is an alpha parameter that is somewhere in between L1 and L2, so for example, if you are using sklearn.SGD_Regressor() alpha=0 is L1 alpha=0.5 is elasticnet, alpha=1 is Ridge.

Lambda

is a term that controls the learning rate. In other words, how much change do you want the model to make during each iteration of learning.

confusion

To make matters worse, these terms are often used interchangedly, I think due to different yet similar concepts in graph theory, statistical theory, mathematical theory, and the individuals who write commonly-used machine-learning libraries

check out some info here: https://www.analyticsvidhya.com/blog/2016/01/complete-tutorial-ridge-lasso-regression-python/ but also look for some of the free academic textbooks about statistical learning.

这篇关于python中alpha和lambda正则化参数的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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