Elastic net regression is a type of regression that combines lasso regression with ridge regression by adding a L1 and L2 regularization term to the `loss`

function.

Implementing elastic net regression should be straightforward after the previous two recipes, so we will implement this in multiple linear regression on the iris dataset, instead of sticking to the two-dimensional data as before. We will use pedal length, pedal width, and sepal width to predict sepal length.

- First we load the necessary libraries and initialize a graph, as follows:
import matplotlib.pyplot as plt import numpy as np import tensorflow as tf from sklearn import datasets sess = tf.Session()

- Now we will load the data. ...

Start Free Trial

No credit card required