Member-only story
Elastic Net Regression: From Sklearn to Tensorflow
How to make an equivalent elastic net regression between sklearn and Tensorflow in Python
This article is intended for the practitioners who want to compare the sklearn and Keras implementation of elastic net regression. Mainly, how to go from Sklearn loss function to Keras (Tensorflow) loss function.
Main parts of the article:
- A brief introduction to regularization in regression.
- Sklearn implementation of the elastic net.
- Tensorflow implementation of the elastic net.
- Going from one framework to another.
- Writing a custom loss function.
- Comparing the results.
All the codes are in my repository: https://github.com/Eligijus112/regularization-python
Regression is a process in machine learning determining the relationship between the mean value of the response variable Y and features X.
The prediction for a model is denoted as y with a hat and is calculated by estimating the coefficients beta from data:
The betas without a hat denote the theoretical model and the betas with a hat denote the practical model, which was obtained…