Ridge, Lasso and Elastic Net Regularization

栏目: IT技术 · 发布时间: 5年前

内容简介:These Regularization methods are used to overcome the problem of over-fitting in Linear Regression modelsOne of the major problem in Linear Regression algorithm is it tries to over-fit the training set and when accuracy is checked on test set it performs v

Ridge, Lasso and Elastic Net Regularization methods

These Regularization methods are used to overcome the problem of over-fitting in Linear Regression models

Jun 7 ·3min read

Ridge, Lasso and Elastic Net Regularization

Ridge and Lasso 2-D Graph.

One of the major problem in Linear Regression algorithm is it tries to over-fit the training set and when accuracy is checked on test set it performs verrryy bad! Therefore, to penalize weight(slope), Regularization methods are used.

Ridge Regression (L2 Regularization)

Ridge Regression Equation is given by,

Ridge, Lasso and Elastic Net Regularization
Ridge Regularization equation

We have seen the first part of this equation i.e. MSE (θ) as the Cost Function in Linear Regression. Here in Ridge Regression, one more term is added to Cost function i.e Regularization term.

‘θ’ denotes weight(slope) applied to the parameters in datasets. As the value of slope increases the model is likely to incline towards over-fitting and if we visualize it, the points connected by these slopes is more of peaks and valleys.

Ridge, Lasso and Elastic Net Regularization

(Source : https://towardsdatascience.com/regularization-the-path-to-bias-variance-trade-off-b7a7088b4577 )

Term ‘α’ penalizes slope having high magnitude. The hyper-parameter α controls how much you want to regularize the model. Higher the value of α, more flatten will be the curve, which leads to under-fitting. On the other hand, if we put lower value of α, model is prone to over-fitting. For α = 0, Cost function(J) will be equal to MSE(θ). Therefore, tuning of α is required to get best from Ridge Regression.

Lasso Regression (L1 Regularization)

Lasso(Least Absolute Shrinkage and Selection Operator) Regression equation is given by,

Ridge, Lasso and Elastic Net Regularization
Lasso Regularization equation

In Lasso, magnitude of weight(slope) is taken into consideration unlike square of weights in Ridge Regression. Hyper-parameter ‘α’ has the same function that was in Ridge. An important characteristic of Lasso Regression is that it tends to completely eliminate the weights of least important features (i.e., set them to zero). In other words, it automatically performs feature selection and outputs a sparse model (i.e., with few nonzero feature weights).

If we use Lasso regression and accuracy comes out to be less then it’s OK because Linear and Ridge Regression has n-dimension but Lasso yields less dimensions comparatively, with very less decrease in accuracy which is good for building production model.

Elastic Net

Elastic Net is a middle ground between Ridge Regression and Lasso Regression. The regularization term is a simple mix of both Ridge and Lasso’s regularization terms, and you can control the mix ratio r. When r = 0, Elastic Net is equivalent to Ridge Regression, and when r = 1, it is equivalent to Lasso Regression.

Elastic Net Regularization equation

Conclusion

So what to choose for our project, should we choose Linear Regression(i.e. without any Regularization), Ridge or Lasso?

It is always advisable to use some amount of Regularization so as to eliminate over-fitting in case of Linear Regression. So, now it boils down to whether to choose Ridge or Lasso.

Ridge is a good default, but if you suspect that only a few features are actually useful, you should prefer Lasso or Elastic Net since they tend to reduce the useless features’ weights down to zero as we have discussed. In general, Elastic Net is preferred over Lasso since Lasso may behave erratically when the number of features is greater than the number of training instances or when several features are strongly correlated.

Got any questions?

GitHub

LinkedIn

Email: amarmandal2153@gmail.com

Thank youuuu…


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

免费

免费

克里斯•安德森 / 蒋旭峰、冯斌、璩静 / 中信出版社 / 2012-10 / 68.00元

一种商业模式既可以统摄未来的市场,也可以挤垮当前的市场——在我们这个现代经济社会里,这并不是一件不可能的事情。 “免费”就是这样的一种商业模式,它所代表的正是数字化网络时代的商业未来。 在《免费》这本书中,克里斯•安德森认为,新型的“免费”并不是一种左口袋出、右口袋进的营销伎俩,而是一种把货物和服务的成本压低到零的新型卓越能力。在20世纪“免费”是一种强有力的推销手段,而在21世纪它已经成为......一起来看看 《免费》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

SHA 加密
SHA 加密

SHA 加密工具

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具