Logistic regression

Now we can try a more complex example implementing a logistic regression algorithm. The first step, as usual, is to create a dummy dataset:

from sklearn.datasets import make_classificationnb_samples = 500X, Y = make_classification(n_samples=nb_samples, n_features=2, n_redundant=0, n_classes=2)

The dataset is shown in the following graph:

Dataset employed for a logistic regression with TensorFlow

At this point, we can create the graph and all placeholders, variables, and operations:

import tensorflow as tfgraph = tf.Graph()with graph.as_default():    Xt = tf.placeholder(tf.float32, shape=(None, 2), name='points') Yt = tf.placeholder(tf.float32, ...

Get Machine Learning Algorithms - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.