How to do it...

We proceed with the recipe as follows:

  1. We start by loading the necessary libraries. This will include the scikit-learn dataset library for access to the iris dataset. Use the following code:
import matplotlib.pyplot as plt 
import numpy as np 
import tensorflow as tf 
from sklearn import datasets 
To set up scikit-learn for this exercise, we just need to type $pip install -U scikit-learn. Note that it also comes installed with Anaconda as well.
  1. Next, we start a graph session and load the data as we need it. Remember that we are loading the first and fourth variable in the iris dataset as they are the sepal length and sepal width. We are loading the target variable, which will take on the value 1 for I. setosa and -1 otherwise. ...

Get TensorFlow Machine Learning Cookbook - Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.